【问题标题】:ODBC driver with two versions of PHP带有两个 PHP 版本的 ODBC 驱动程序
【发布时间】: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


【解决方案1】:

原来错误信息中提供的链接不是我需要的。

我需要的文件是 msodbcsql.msi

可以在以下位置找到:https://www.microsoft.com/en-us/download/details.aspx?id=36434

作为补充说明。 PHP 7 需要 Windows ODBC 驱动程序版本,该版本不适用于 win 2008 R2

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 2022-06-27
    • 2017-01-17
    相关资源
    最近更新 更多