Install Microsoft SQL Server Driver in WAMP

Back to Blog
microsoft sql server with mysql in yii-framework - ezeelive technologies

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.
microsoft sqlserv driver install in php-bin wamp ezeelive technologies
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

Share this post

Comments (7)

  • arethakitchens Reply

    I am actually glad to glance at this webpage posts which contains plenty of useful information, thanks for providing such information.

    March 12, 2014 at 8:14 am
  • samir shah Reply

    Thanx a lot man u have solve my big problem…

    May 4, 2018 at 1:26 am
  • Php On Web Reply

    Hi dude, i have also find out one good example Install PHP and Mysql – WAMP Server

    August 24, 2018 at 1:07 pm
  • Uli Lehmann Reply

    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.

    November 20, 2018 at 2:46 pm
    • Jeremy Nicolls Reply

      @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)

      November 29, 2018 at 1:02 am
  • Sheetal Kulkarni Reply

    Is this all steps are same for xampp please help me any one

    October 18, 2019 at 11:21 am
  • Nancy Thakkar Reply

    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

    January 28, 2020 at 11:18 am

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Blog