PHP - Install the SQL Server driver in the php.ini file
by
Jeremy Canfield |
Updated: March 11 2020
| PHP articles
Determine if PHP currently supports SQL Server functions, such as the sqlsrv_connect function. If no matches are found, PHP does not have support for SQL Server.
- Load the phpinfo.php page in a Web browser (http://www.example.com/phpinfo.php)
- Press Ctrl F, type sqlsrv, and press Enter.
Follow these steps to download the PHP SQL Server DLL files.
- Go to https://www.microsoft.com/en-us/download/details.aspx?id=20098
- Select the Download button
- Check SQLSRV32.EXE and select Next
- If prompted to run or save the file, select Save
- Go to your Downloads folder
- Create a new folder named SQLSRV32
- Run the SQLSRV32 executable file
- In the Microsoft Drivers 3.2 for PHP for SQL Server dialog box, select Yes to accept the end user license agreement (EULA)
- When prompted to select a directory to extract the driver, select C:/Users/username/Downloads/SQLSRV32. The extract should complete, and about 10 .dll files will be extracted to the SQLSRV32 folder.
- Move the .dll files from C:/Users/username/Downloads/SQLSRV32 to the directory where the .dll files are stored, which is probably C:/PHP/ext or C:/Program Files/PHP/vx.x/ext/.
Edit the PHP.ini file:
- Open the PHP.ini file in a text editor, such as notepad or notepad++. The PHP.ini file will probably be listed at C:/PHP/PHP.ini or C:/Program Files/PHP/vx.x/PHP.ini.
- Locate the Extensions area of the PHP.ini file. This might be at the very bottom of the file.
- Add the following to the Extensions area:
Extension=php_sqlsrv_56_ts.dll
- Save and close the PHP.ini file.
Restart IIS:
- In the left panel of IIS, select the root directory
- In the right panel of IIS, select Restart
Verify the php_sqlsrv_56_ts.dll file is enabled:
- In the middle area of IIS, select PHP Manager
- Select Eanble or disable an extension
- Ensure php_sqlsrv_56_ts.dll is listed and Enabled
Verify PHP now supports SQL Server functions:
- Load the phpinfo.php page in a Web browser (http://www.example.com/phpinfo.php)
- Press Ctrl F, type sqlsrv, and press Enter.
If no matches are found, PHP does not have support for SQL Server.
Did you find this article helpful?
If so, consider buying me a coffee over at