Question

I have installed:

  1. Windows Server 2008 R2 x64
  2. IIS 7
  3. PHP 5.5 (5.5.9) VC11 x64 Non Thread Safe (2014-Feb-06 00:36:15)
  4. MSVC11 (Visual C++ 2012)
  5. Sql Server 2008
  6. Sql Native Client

Everything works perfectly except the MSSQL driver for PHP. I have Googled a lot and downloaded lots of dll files. Every time I get this error:

PHP Warning: PHP Startup: Unable to load dynamic library c:\php\ext\php_sqlsrv_54_nts.dll - %1 is not a valid Win32 application. in Unknown on line 0

Can anyone tell me that how can I find the specified driver? Thanks in advance.

Was it helpful?

Solution

There's a clue in the file name php_sqlsrv_54_nts.dll

The "54" refers to PHP 5.4. The SQL Driver doesn't (officially) exist yet for PHP 5.5.

:(

Some people have worked on unofficial builds, but I would only use them for local testing. Microsoft sqlsrv extension for php 5.5.x

At present official releases only work with 5.4.x

OTHER TIPS

Here is a page from my blog with instructions on how to install the driver: http://robsphp.blogspot.com/2012/09/how-to-install-microsofts-sql-server.html

Look for text written in in orange which refers to my builds of the driver that support PHP 5.5 32 and 64 bit.

If you only want Microsoft's builds, avoid looking at anything written in orange.

Sharing some of my findings:

  1. Architecture matters(x86 / x64)
  2. PHP version matters a lot
  3. Matching SQL Driver Should be installed.
  4. Refer This Link to find whether your PHP version supports the driver (Refer the first table).
  5. Refer Rob's Answer to find your Architecture and TS/NTS (Thread Safe/Non Thread Safe) of Your PHP This is His Blog
  6. This is what worked out for me: I tried with Wampp - 64bit, Selected PHP 7.0.10 downloaded MYSQL Driver version 5.3 (Note: Refer the table i mentioned- 4th point to get the correct version)
  7. Saved only the 64 bit TS (php_sqlsrv_7_ts_x64.dll, php_pdo_sqlsrv_7_ts_x64.dll) because my php was Thread Safe (You can find yours by refering 5th point) into the E:\wamp64\bin\php\php7.0.10\ext folder.
  8. Added extension=php_sqlsrv_7_ts_x64.dll and extension=php_pdo_sqlsrv_7_ts_x64.dll to the php.ini, selected from wampp menu (E:\wamp64\bin\apache\apache2.4.23\bin\php.ini).
  9. Restarted Wampp, and it works perfect.
  10. For those who face call to undefined function sqlsrv_connect() also can follow this technique.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top