【发布时间】:2017-01-11 14:49:12
【问题描述】:
我在已经存在的 php 5.5 旁边安装了 php 5.6
除了连接到 sqlserver 之外,一切似乎都工作正常
这是我的测试 php 脚本:
$connectionInfo = array( "Database"=>"$DB", "UID"=>"$DBUSER", "PWD"=>"$DBPASS");
$cn = sqlsrv_connect($DBSERVER, $connectionInfo);
$strErrors = getSQLErrors();
if ($strErrors != "")
die($strErrors);
sqlsrv_close($cn);
function getSQLErrors($ignoreWarnings = false)
{
$retVal = "";
$err = sqlsrv_errors();
if ($err)
{
foreach( $err as $error )
{
if (!$ignoreWarnings || ($ignoreWarnings && $error['SQLSTATE'] != 1000)) // ignore warnings
$retVal .= "SQLSTATE: ".$error[ 'SQLSTATE'].". Code: ".$error[ 'code'].". Message: ".$error[ 'message']."\r\n\r\n";
}
}
return $retVal;
}
这是我得到的错误:
SQLSTATE: IMSSP. Code: -49. Message: This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL t
o download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712
SQLSTATE: IM002. Code: 0. Message: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
我的 ext 文件夹和 php.ini 中已经有以下内容:
php_sqlsrv_56_nts.dll
php_pdo_sqlsrv_56_nts.dll
我的路径环境变量指向我的 5.6 php。
php.ini文件中的相关路径也都指向5.6版本。
还有什么我需要注意的吗?在我拔掉所有头发之前,谁能帮帮我?
【问题讨论】:
-
此扩展需要 Microsoft ODBC Driver 11 for SQL Server。访问以下 URL 以下载适用于 x86 的 SQL Server 的 ODBC 驱动程序 11:http://go.microsoft.com/fwlink/?LinkId=163712
-
是的 - 已经这样做了,而且它仍然存在。
标签: php sql-server windows-server-2008-r2