Install Microsoft SQL Server Driver in WAMP
Install Microsoft SQL Server Driver in WAMP
Most of PHP developer very much familiar with MySQL Database but We talk about Microsoft SQL Server we find lack for knowledge on PHP with SQL Server even on the google and php.net official website. Even the hosting company provide Pre-installed PHP and MySQL on the Server.
Here some explicit instructions for Install Microsoft SQL Server Driver in WAMP with PHP 5.3 :
1. Open //www.microsoft.com/en-us/download/details.aspx?id=20098 for Download Microsoft SQLServ PHP Driver
2. Download SQLSRV30.EXE (Windows Vista, Server 2008, Windows 7 or above) or SQLSRV20.EXE (Server 2003/Windows XP or below).
3. Run SQLSRV30.EXE and enter your PHP bin folder path to Install Driver DLL files.
4. Open php.ini file and enable PHP sqlserv extensions
extension=php_pdo_sqlsrv_53_ts.dll extension=php_sqlsrv_53_ts.dll
5. Restart All services in WAMP and confirm pdo_sqlsrv extension enable in phpinfo
6. Put your database connection string detail and User below PHP code to check database connection. Write a PHP script that connects to your SQL Server database using the sqlsrv functions. Here’s a simple example:
<?php $serverName = "hostname or ip"; $connInfo = array("Database"=>"db_name", "UID"=>"db_username", "PWD"=>"db_password"); $conn = sqlsrv_connect($serverName, $connInfo); if($conn){ echo "Database connection established.<br />"; }else{ echo "Connection could not be established.<br />"; die( print_r(sqlsrv_errors(), true)); } ?>
7. If you encounter any errors, double-check the PHP error log (php_error.log) and the SQL Server driver documentation for troubleshooting.
If you find any problem or difficulty, please fill free to contact us or leave a comment
Comments (7)
I am actually glad to glance at this webpage posts which contains plenty of useful information, thanks for providing such information.
Thanx a lot man u have solve my big problem…
Hi dude, i have also find out one good example Install PHP and Mysql – WAMP Server
Hi,
I am a Little lost here:
in my Setup the Drivers do not load and in phphinfo I do not find “pdo_sqlsrv” :(.
here my Setup:
Drivers are in Directory:
c:\wamp64\php\php7.2.10\ext
php.ini:
extension=php_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll
done the restart but nothing works – can anybody help me.
Thank you.
@Uli Lehmann – I had the same problem when trying to run php version 7.2.10. I believe that the current microsoft drivers only support version 7.0.
Configure wampserver to use PHP 7.0.32
Download and install SQLSRV40 to this location:
C:\wamp64\bin\php\php7.0.32\ext
add the following lines to the php.ini
extension=php_sqlsrv_7_ts_x64.dll
extension=php_pdo_sqlsrv_7_ts_x64.dll
Restart apache (or all services which is easier)
Is this all steps are same for xampp please help me any one
I have tried using Wampserver 3.1.9 64 bit and PHP version 7.2.18 but showing error
Error : Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect()
Error: Call to undefined function sqlsrv_connect()
Please help if any one knows the issue.
I have checked php extensions & php.ini file extensions are added into it:
extension=php_pdo_sqlsrv_54_nts.dll
extension=php_pdo_sqlsrv_54_ts.dll
extension=php_pdo_sqlsrv_55_nts.dll
extension=php_pdo_sqlsrv_55_ts.dll
extension=php_pdo_sqlsrv_56_nts.dll
extension=php_pdo_sqlsrv_56_ts.dll
extension=php_sqlsrv_54_nts.dll
extension=php_sqlsrv_54_ts.dll
extension=php_sqlsrv_55_nts.dll
extension=php_sqlsrv_55_ts.dll
extension=php_sqlsrv_56_nts.dll
extension=php_sqlsrv_56_ts.dll
please help if anyone knows the issue or solution of this.
Thanks in advance