Home >Database >Mysql Tutorial >Why is my PHP Function 'sqlsrv_connect()' Not Found in XAMPP?

Why is my PHP Function 'sqlsrv_connect()' Not Found in XAMPP?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-27 12:59:20477browse

Why is my PHP Function 'sqlsrv_connect()' Not Found in XAMPP?

PHP: Function 'sqlsrv_connect()' Not Found

Introduction

XAMPP users may encounter a fatal error when attempting to connect to Microsoft SQL Server using the sqlsrv_connect(). The error message "Call to undefined function sqlsrv_connect()" indicates that the PHP extension for SQLSRV is not properly installed or loaded.

Step-by-Step Solution

To resolve this issue, follow these steps:

  1. Download the SQLSRV Driver:
    Download the Microsoft Drivers for PHP for SQL Server (SQLSRV) from the official website: http://www.microsoft.com/en-us/download/details.aspx?id=20098
  2. Extract the Driver:
    Extract the downloaded ZIP file into the XAMPP PHP extension directory (usually located at "C:xamppphpext").
  3. Enable the Extension:
    In the "php.ini" file, locate the line "extension = php_sqlsrv_56.dll" (or "php_pdo_sqlsrv_56.dll"). If this line is commented out, remove the semicolon (;).
  4. Restart Apache:
    Restart the Apache web server from the XAMPP control panel to load the extension.

Conclusion

Following these steps should enable the sqlsrv_connect() function and allow you to connect to Microsoft SQL Server from your PHP application in XAMPP. Please ensure that you have granted the necessary permissions to the PHP user in the SQL Server instance.

The above is the detailed content of Why is my PHP Function 'sqlsrv_connect()' Not Found in XAMPP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn