在使用PHP中的sqlsrv_connect
的windows 2003服务器上使用sqlsrv连接mssql服务器2008时,我收到以下错误。已安装Microsoft SQL Server 2008 Native Client。在IIS 6.0 上运行的Web服务器
以下是php.ini内容
==========================
[PHP_SQLSRV]
extension=php_sqlsrv_53_ts_vc9.dll
[PHP_PDO_SQLSRV]
extension=php_pdo_sqlsrv_53_nts_vc6.dll
php_pdo_sqlite.dll
==========================
Array
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -49
[code] => -49
[2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712
[message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712
)
[1] => Array
(
[0] => IM002
[SQLSTATE] => IM002
[1] => 0
[code] => 0
[2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
[message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
)
)
两种尝试方法,
首先检查本机驱动程序是否具有正确的版本-
您的服务器真的是32位版本而不是84位版本吗?
另一件事是,检查扩展是否真的加载了。
要检查这一点,请创建一个类似"phpinfo.php"的文件,并将其放在.htdocs.的文件夹中
<?php
// show phpinfo file
phpinfo();
?>
简单的方法是用Ctrl+F和"extension=php_sqlsrv_53_ts_vc9.dll"在phpinfo页面中搜索它
- 转到此网站:Microsoft下载网站
- 滚动到
(+) Install Instructions
部分,然后单击它 - 在此部分内滚动至:
Microsoft® SQL Server® 2012 Native Client
- 你会在那里看到两个链接:安装其中一个(最多32或64个系统)
X86包(sqlncli.msi)X86直接链接
X64包(sqlncli.msi)在评论中的直接链接
确保安装了Microsoft SQL Server 2012 Native Client。遵循PHP要求