无法在 IIS 上使用 PHP 连接到 MSSQL
我已经寻找解决方案两天了。我得到以下效果:
array(2) {
[0] => array(6) {
[0] => string(5) "IMSSP"
["SQLSTATE"] => string(5) "IMSSP"
[1] => int(-49)
["code"] => int(-49)
[2] => string(390) "This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712"
["message"] => string(390) "This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712"
}
[1] => array(6) {
[0] => string(5) "IM002"
["SQLSTATE"] => string(5) "IM002"
[1] => int(0)
["code"] => int(0)
[2] => string(91) "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
["message"] => string(91) "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
}
}
看起来没有“Microsoft SQL Server 2008 R2 Native Client”,但有!
我已经在本地计算机和测试服务器上使用了相同的配置。 当没有安装“Microsoft SQL Server 2008 R2 Native Client”时,我在本地计算机上遇到相同的错误。安装后问题就解决了。
不幸的是,我在这里看不到任何变化。
我尝试了不同的 PHP 和 sqlsrv 驱动程序,但没有效果。
我无法进行太多实验,因为这是实时服务器。
我怎样才能让它发挥作用?这与控制面板 ODBC 设置有关吗?还安装了另一个本机客户端,但我无法从该实时服务器中删除它。
如何阅读这些信息? php sqlsrv 驱动程序是否能看到本机客户端?
编辑
问题是我使用的所有内容都是 32 位的。本机驱动程序也显示在 ODBC 控制面板中。 PHP 的 Sqlsrv 扩展也可以正常工作,如 phpinfo 中所示。
PHP 的 sqlsrv 扩展怎么可能看不到该本机客户端?
我无能为力,现在我正在设置虚拟机,我将在其中设置与网络服务器上完全相同的配置,并进行一些更大胆的实验。
I'm looking for solution for 2 days already. I'm getting following effect:
array(2) {
[0] => array(6) {
[0] => string(5) "IMSSP"
["SQLSTATE"] => string(5) "IMSSP"
[1] => int(-49)
["code"] => int(-49)
[2] => string(390) "This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712"
["message"] => string(390) "This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712"
}
[1] => array(6) {
[0] => string(5) "IM002"
["SQLSTATE"] => string(5) "IM002"
[1] => int(0)
["code"] => int(0)
[2] => string(91) "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
["message"] => string(91) "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
}
}
Looks like there's no "Microsoft SQL Server 2008 R2 Native Client" but there is!
I've already used same configuration on my local machine and test server.
I was getting same error on local machine when there was no "Microsoft SQL Server 2008 R2 Native Client" installed. After installing it the problem was solved.
Unfortunatelly here I can't see any change.
I was trying different PHP and sqlsrv drivers but that had no effect.
I can't experinemt a lot because this is live server.
How can I make this working? Is this have something to do with control panel ODBC settings? There's also another native client installed but I can't remove it from this live server.
How to read this information? Does php sqlsrv driver sees native client at all?
Edit
The problem is that I'm using everything in 32 bit. Native driver is also shown in ODBC control panel. Sqlsrv extension for PHP is also working as shown in phpinfo.
How is that possible that sqlsrv extension for PHP doesn't "see" that native client?
I'm powerless and now I'm setting up VM where I'll set exactly the same cofiguration as on web server and will make some bolder experiments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在服务器上安装 32 位和 64 位驱动程序。 32 位 odbc 控制面板位于 Windows\SysWow64 目录中 - 不太明显,但仅此而已。确保您有可执行文件 (PHP) 的驱动程序 - 如果它是 32 位,则需要 32 位驱动程序。
Install 32 and 64 bit drivers on the server. The 32 bit odbc control panel is located in the Windows\SysWow64 directory - not totally obvious, but that's it. Make sure you have drivers for your executable (PHP) - if it's 32 bit, you need 32 bit drivers.
看来您遇到了与我本周遇到的问题相同的问题,
我下载了 Process Monitor 并按照这篇文章中的说明进行操作
http://www.iislogs.com/articles/processmonitorw3wp/
然后我看到进程 w3wp.exe 在此注册表项上的访问被拒绝
HKLM\Software\ODBC\ODBCINST.INI\SQL Native Client 10.0
我打开 RegEdit 并转到该键。
我右键单击->权限并将网络服务添加到列表中并授予其读取权限。
回收了应用程序池,现在可以使用了!
希望有帮助。
干杯,
费德
It seems that you are having the same issue as I was having this week
I downloaded Process Monitor and followed the instructions on this post
http://www.iislogs.com/articles/processmonitorw3wp/
Then I saw the process w3wp.exe was getting access denied on this registry key
HKLM\Software\ODBC\ODBCINST.INI\SQL Native Client 10.0
I opened RegEdit and went to that key.
I did right click - > Permissions and added Network Service to the list and gave it Read permissions.
Recycled the app pool and it is now working!
Hope it helps.
Cheers,
Fede