Home >Database >Mysql Tutorial >How to Fix the 'Fatal Error: Call to Undefined Function sqlsrv_connect()' in XAMPP?
Fatal Error: Call to Undefined Function sqlsrv_connect()
Encountering the "Fatal error: Call to undefined function sqlsrv_connect()" error while using XAMPP with PHP and connecting to Microsoft Azure SQL Server indicates a missing requirement.
Solution 1:
The MSSQL extension is no longer available for PHP 5.3 or later on Windows. Instead, Microsoft provides SQLSRV, an alternative driver for SQL Server.
Solution 2:
Step 1: Download SQLSRV
Visit http://www.microsoft.com/en-us/download/details.aspx?id=20098 to download SQLSRV32.EXE (Microsoft Drivers for PHP for SQL Server).
Step 2: Extract and Place the DLL File
Extract the downloaded file and copy SQLSRV32.EXE to C:xamppphpext.
Step 3: Add Extension to php.ini
Uncomment or append the following line to your php.ini file:
extension=php_sqlsrv_56_ts.dll
Step 4: Restart Apache
Restart Apache from the XAMPP Control Panel to apply the changes.
Alternative Source for Compiled Binaries
You can also find the most recent compiled binaries in the official Microsoft Git repository.
Note:
Ensure that you are using the compatible version of SQLSRV for your PHP version installed in XAMPP. This error can occur if the extension version is incompatible with PHP.
The above is the detailed content of How to Fix the 'Fatal Error: Call to Undefined Function sqlsrv_connect()' in XAMPP?. For more information, please follow other related articles on the PHP Chinese website!