16

Here is my setup

  • Windows Server 2008 R2 64 bit
  • Apache 2.4.4 64 bit
  • PHP 5.4.15 32 bit (64 bit is still experimental), thread safe, VC9 compiler
  • Microsoft SQL Server 2012 Native Client 64-bit
  • Microsoft Visual C++ 2010 x86 and x64

I need to load Microsoft's SQLSRV library.

I have added 'extension=php_sqlsrv_54_ts.dll' to php.ini and copied 'php_sqlsrv_54_ts.dll' to the ext folder where PHP is installed.

When I restart apache, I get the following error in my php error log, and SQLSRV is not listed in phpinfo.

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\php5\ext\php_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.

Where am I going wrong?

EDIT For testing purposes I've just installed PHP 5.5.10 64 bit and VC 2012 but the error remains the same :(

5
  • Just guessing here, but I'm not sure if 32bit application (PHP) can load x64 dll (SQL server). Mar 20, 2014 at 10:38
  • 2
    Thanks for the comment. Wouldn't php_sqlsrv_54_ts.dll be 32 bit though? I downloaded from microsoft.com/en-gb/download/details.aspx?id=20098 and can't see any reference to whether it is 32 bit or 64 bit.
    – iltdev
    Mar 20, 2014 at 10:41
  • Not sure why the downvotes. It would be useful to know WHY then I can provide the information you require.
    – iltdev
    Mar 20, 2014 at 10:57
  • 3
    It's harsh to have a question down voted, this site would be useless without the questions. However, it might be because 32-bit TS PHP using the Apache module would not work at all with 64-bit Apache. You would have to use mod_fcgid with 32-bit PHP NTS, or 32-bit Apache instead of 64-bit. (I just upvoted your question back to 0!)
    – Rob
    Jul 11, 2014 at 22:14
  • Thanks Rob. Really useful comment and certainly sounds logic. I'll hopefully give it a try, though I am quite impress with UniServer Zero. It got me up and running very quickly :)
    – iltdev
    Jul 17, 2014 at 15:39

4 Answers 4

13

I don't know if it helps but i used all 32bit on my Windows 7 64bit system

Here is what I used and i can use SQL Server

httpd-2.4.6-win32-VC9 //apache 2.4
php-5.4.9-Win32-VC9-x86 //php5

inside if my \php\ folder i have

  • php5apache2_4.dll

Inside \php\ext\ i have

  • php_pdo_sqlsrv_54_nts.dll
  • php_pdo_sqlsrv_54_ts.dll

I added this to the end of php.ini

[PHP_SQLSRV]
extension=php_sqlsrv_54_ts.dll
[PHP_PDO_SQLSRV]
extension=php_pdo_sqlsrv_54_ts.dll

I remember it being a right pain getting it to work but it does now. If i remember anymore i'll edit my answer

UPDATE:

I think this blog post looks familiar on how i got it working

http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html

3
  • 1
    Thanks AdRock. I'll have a go with your setup and report back as soon as I can. Maybe 64 bit Apache is where it falls over for me.
    – iltdev
    Mar 20, 2014 at 11:15
  • I never managed to get this working. I tried numerous tutorials and forums, so I'm sure this answer is correct. There must be a setting somewhere in my setup that causes an issue. Maybe its Apache 2.4 64bit? I decided to use The Uniform Server uniformserver.com instead. Following the above steps worked perfectly.
    – iltdev
    Mar 27, 2014 at 12:19
  • 7
    If you are using Apache 64 bit, you currently have 2 ways to load PHP with SQLSRV: 1. Use PHP 5.5 64 bit build and custom php_sqlsrv driver build from robsphp blog pages link 2. Get 32-bit PHP and use Apache's mod_fcgid module. It allows loading 32-bit cgi modules in 64-bit Apache: link
    – Rob
    Jun 13, 2014 at 15:38
4

I had the same issue. Running a legacy 5.6 php x64 which needed the interface because of the hard RAM restrictions 32 bits give.

The solution was in the unoffical driver offered by Rob.

https://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html

I tested it out, and it works properly with 5.6.33 x64

3

currently Microsoft sqldriver only works for 32bit php version. Here is my steps to install sql drivers.

0

Sqlsrv requires php x86. This message appears when php is 64 bit architecture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.