0

I've read a lot of posts here on this problem, but I think mine is a little different because the output I'm getting doesn't match what others have had.

I am running WampServer Version 3.1.4 64bit and trying to connect to a SQL Server DB and I get the following error:

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() using the following code:

$serverName = "xxx.xxx.xxx.xxx";
$connectionInfo = array("Database" => "db_name", "UID"=>"sa", "PWD"=>"db_pwd");
$conn = sqlsrv_connect($serverName, $connectionInfo);

I have tried the following:

  • I downloaded the sql drivers for PHP 7 and 7.1 and tried them with the corresponding PHP versions
  • I made sure to restart all services after updating the php.ini file.
  • With my version of WAMP the php.ini file in the Apache folder is just a shortcut to phpForApache.ini in the php7.1.22 folder and it updates automatically.
  • The extensions DO show up in the WAMP menu: PHP > PHP extensions and they have the green check mark next to them

I consistently get the following in my php_error.log:

[27-Nov-2018 14:25:16 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.22/ext/php_sqlsrv_71_nts.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0
[27-Nov-2018 14:25:16 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.1.22/ext/php_sqlsrv_71_ts.dll' - %1 is not a valid Win32 application.
 in Unknown on line 0

As stated, I've tried using the appropriate dlls for both php 7 and 7.1.22 and got the same output:

[27-Nov-2018 15:12:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.0.32/ext/php_sqlsrv_7_ts_x86.dll' - %1 is not a valid Win32 application.

 in Unknown on line 0

[27-Nov-2018 15:12:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php7.0.32/ext/php_sqlsrv_7_nts_x86.dll' - %1 is not a valid Win32 application.

I'm really not sure what other config I must be missing. I also tried the x64 versions, but I get an error stating the file could not be found, even though I triple checked the location.

Seeing as I get the same not a valid Win32 application error for both versions, I guess it's something outside of PHP

Adam Hey
  • 1,512
  • 1
  • 20
  • 24
  • Per https://stackoverflow.com/questions/36593213/unable-to-load-dynamic-library-php-sqlsrv-7-nts-dll-is-not-a-valid-win32-applica, you may be missing the Visual C++ 2015 Runtime and ODBC drivers. Can you verify that the pre-requisites have been installed? – Mr Griever Nov 27 '18 at 16:03
  • yes - I tried installing the Visual C++ Redistributable and and windows told me it was already installed – Adam Hey Nov 27 '18 at 16:05
  • You mentioned that you are running the 64-bit version of WAMP, however it appears that the sqlsrv drivers are 32-bit and failing to load in a 64-bit context. Try either switching to a 32-bit WAMP, or else find a 64-bit version of the sqlsrv drivers (see: http://robsphp.blogspot.com/2012/06/unofficial-microsoft-sql-server-driver.html) – Mr Griever Nov 27 '18 at 16:09
  • I just checked the installed versions and I have 2005, 2008, 2010, 2012, 2013 and 2017. Some are x86, but most are x64 – Adam Hey Nov 27 '18 at 16:09
  • I've tried both 32 and 64 bit versions of the sql drivers. With the 64 bit versions, I got a "file not found" error in my php error log – Adam Hey Nov 27 '18 at 16:10

0 Answers0