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 thephp7.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