sqlsrv drivers doesn't appear on a WAMP server phphinfo() after adding the extension entries in the php.ini file

13,417

Solution 1

64 bit WAMP server was not able to connect using the drivers extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;

So, I installed a 32 bit version of the WAMP server and it works fine now.

Solution 2

Check the php error log (c:\wamp\logs\php_error.log). I had the same setup (64bit WAMP/PHP 5.5.12) and same missing sqlsrv reference in phpinfo and I got this error in my log:

PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.5.12/ext/php_pdo_sqlsrv_55_ts.dll' - %1 is not a valid Win32 application. in Unknown on line 0

The solution was to install the 64bit version of the sqlsrv drivers. I found the unofficial 64bit drivers through http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html

Warning: In my testing I found these 64bit PHP_PDO_SQLSRV extension 10 times slower than when using PHP_PDO_ODBC.

Share:
13,417
user2569524
Author by

user2569524

Updated on July 24, 2022

Comments

  • user2569524
    user2569524 almost 2 years

    I wanted to setup a database connection from PHP to SQL server 2012.I have a wamp server(64 bit) set up on a windows machine(64 bit) with PHP 5.5.12 and on the same machine I have SQL server 2012 installed.

    Extracted sqlsrv drivers from official_link

    Copied the extracted drivers php_sqlsrv_55_ts.dll, extension = php_pdo_sqlsrv_55_ts.dll to php\ext folder, and then changed the php.ini file to include the extensions

    extension = php_sqlsrv_55_ts.dll; extension = php_pdo_sqlsrv_55_ts.dll;
    

    Now I tried

    <?php
      phpinfo();
     ?>
    

    I see the following information without any SQL server information in it.

    enter image description here

    enter image description here

    Don't seem to have configured SQL server connection successfully. Could some one please guide me on what I am missing here.

    • Funk Forty Niner
      Funk Forty Niner over 9 years
      Did you restart all services and maybe even rebooted after making the changes? If not, do.
    • user2569524
      user2569524 over 9 years
      Yes I restarted all the services.
    • RiggsFolly
      RiggsFolly over 9 years
      Have you also download and installed the Microsoft SQL Server 2012 Native Client and Microsoft ODBC Driver 11. Remember the php extensions do not talk directly to the database, they talk to the Native Client. See the System Requirements section on the download page you reference above.
    • user2569524
      user2569524 over 9 years
      @RiggsFolly I have complete SQL server installed on the same machine, so I already have 'Microsoft SQL Server 2012 Native Client' installed by default that came with sql server installation. I checked ODBC administrator to confirm.
    • Franklin P Strube
      Franklin P Strube over 9 years
      Can you try executing the php.exe from a command prompt. It may give you additional error output that you cannot see on the web.
    • UnskilledFreak
      UnskilledFreak over 9 years
      sorry if im wrong (i dont use mssql) but is this an simple extension or a zend extension?
    • risyasin
      risyasin over 9 years
      You have to compile php from source. with "--with-mssql" option. since pecl does not support any pdo/mssql/sybase extension on windows. windows.php.net/downloads/pecl/releases
    • KTYP
      KTYP over 9 years
      try non thread safe version of sql driver for php. also if you can try 32bit version of wamp with sql server driver i had a terrible experience with 64bit wamp and mssql ;)
    • Pouya Darabi
      Pouya Darabi over 9 years
      clear wamp's logs , and restart wamp, read log , it's must contain a error ,that explain why dll not loaded!