简体   繁体   中英

“could not find driver” error when using PDO with MSSQL server

This question has been asked many times and I've gone through all of them and none of the solutions have worked for me.

Basically,

I am getting "could not find driver" exception when connecting to MSSQL server using PDO. Below is my spec:

Windows 8 - 64 Bit version
MSSQL server 2008 R2 - 64 bit version
Wampserver 2.4 - 64 bit version with PHP 5.4 (Thread Safe version)

This what I have done so far:

  1. Downloaded SQLSRV - version 3.0 from here
  2. Placed the "php_pdo_sqlsrv_54_ts.dll" and "php_sqlsrv_54_ts.dll" files in "c:/wamp/bin/php/php.xx/ext" directory (have used php_ * sqlsrv ts**.dll because I am using thread safe version of PHP)
  3. Enabled them in php.ini ( I know there are two php.ini files in wampserver and I have edited this in the correct php.ini )
  4. Restarted wampserver

But still I am getting the same error.

Can anyone please help me resolve this error?

Output of phpinfo();

Found following in the error logs of Apache:

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

在此处输入图片说明

For those who run into the above problem here's the solution.

Apparently Microsoft don't have a 64 bit version of SQLSRV driver. Switching to a 32 bit version of wampserver solved the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM