Home > Database > Mysql Tutorial > Why am I getting a 'Fatal error: Call to undefined function sqlsrv_connect()' when connecting to Microsoft Azure SQL Server with XAMPP and PHP 5.6.8?

Why am I getting a 'Fatal error: Call to undefined function sqlsrv_connect()' when connecting to Microsoft Azure SQL Server with XAMPP and PHP 5.6.8?

Mary-Kate Olsen
Release: 2024-12-24 15:30:10
Original
582 people have browsed it

Why am I getting a

Fatal Error: Undefined Function 'sqlsrv_connect()'

When trying to connect to a Microsoft Azure SQL server using XAMPP with PHP 5.6.8, an error message of "Fatal error: Call to undefined function sqlsrv_connect()" may occur. This error indicates that the PHP extension for SQL Server (SQLSRV) is not installed or not properly configured.

Solution:

To resolve this error, install the SQLSRV extension for PHP. Here are the steps:

  1. Download the SQLSRV Extension:

    • Visit Microsoft's download page for the SQLSRV extension: http://www.microsoft.com/en-us/download/details.aspx?id=20098
  2. Choose Your Platform:

    • Select the version of Windows and PHP that you are using.
  3. Install the Extension:

    • Run the downloaded executable file (SQLSRV32.EXE) and follow the installation instructions.
  4. Enable the Extension in PHP.ini:

    • Open the php.ini file located in the XAMPP installation directory (e.g., C:xamppphpphp.ini).
  5. Uncomment or Add the Extension Line:

    • Locate or add the following line in the php.ini file:

      extension=php_sqlsrv_56_ts.dll
      Copy after login
  6. Save and Restart Apache:

    • Save the changes to php.ini and restart the Apache server from the XAMPP control panel.

Additional Notes:

  • Make sure you select the correct version of the SQLSRV extension compatible with your PHP version (56_ts for PHP 5.6.8).
  • The SQLSRV extension is no longer bundled with PHP by default, so it must be installed separately.
  • If you encounter any issues during installation or configuration, refer to the Microsoft documentation or consult with a PHP developer.

The above is the detailed content of Why am I getting a 'Fatal error: Call to undefined function sqlsrv_connect()' when connecting to Microsoft Azure SQL Server with XAMPP and PHP 5.6.8?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template