'Error!: could not find driver' after installing php_[pdo_]mssql.dll on WampServer

戏子无情 提交于 2019-12-25 04:24:13

问题


Similar questions seem to be all over the internet, but so far nothing has helped.

I'm currently running WampServer with Apache 2.4.4 and PHP 5.4.12 on Windows Server 2008 R2. According to the PHP documentation the drivers necessary to connect to an MSSQL server ship with the distribution; they do not. Neither php_mssql.dll (which the documentation claims is no longer necessary for PHP5.4, but which is still referenced in php.ini. Who knows) nor php_pdo_mssql.dll are present in the distribution.

Several sources pointed to these drivers from Microsoft, however I had no success either renaming the respective drivers to php_mssql.dll/php_pdo_mssql.dll or keeping the names the same (php_sqlsrv_54_nts.dll, php_pdo_sqlsrv_54_ts.dll, etc.) and modifying php.ini to point to the proper driver. Though I didn't get an error upon starting apache as I do when the driver is simply missing, I received Error!: could not find driver when attempting to point to a test php page at localhost.

This article seemed the most promising, but unfortunately ntwdblib.dll is not included in the zip distributions of PHP, contrary to what the article claims. This seems like it should be a laughably simple problem: missing drivers, which are supposedly readily available. And yet here I am... What am I doing wrong?


回答1:


In case anyone else ends up here while trying to solve this problem, here are the steps that have worked for me the two times I've done it. These steps worked both on Windows Server 2008 R2 and Windows 8.

For my purposes, I used the latest 32-bit (x86) version of WampServer (at the time of this writing, it was 2.4, and came with Apache 2.4.4 and PHP 5.4.16). The 32-bit version is necessary, as the drivers are 32-bit; the 64-bit version will not work.

  1. Install Microsoft Visual C++ 2010 Redistributable Package x86
  2. Install Microsoft SQL Server 2008 Native Client x86 (Click "Download" and select ENU\x86\sqlncli.msi. Once again, the 64-bit version will not work)
  3. Install Microsoft ODBC Driver 11 x86 (Click "Download" and select 1033\x86\msodbcsql.msi)
  4. Install Microsoft SQLSRV driver 3.0 in php/ext/ (For my installation, this was C:/wamp/bin/php/php5.4.16/ext/)
  5. Edit Apache's php.ini to include the line extension=php_pdo_sqlsrv_54_ts.dll (for my installation, this was located in C:/wamp/bin/apache/Apache2.4.4/bin/)



回答2:


You have to place the file in the directory for PHP/ext (bin/php/ext depending on your Wamp / Xampp installation). However, you also need the SQL server native client as per: http://msdn.microsoft.com/en-us/library/cc296170.aspx



来源:https://stackoverflow.com/questions/20153869/error-could-not-find-driver-after-installing-php-pdo-mssql-dll-on-wampserv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!