我得到了这个错误:
“此扩展需要Microsoft ODBC Driver for SQL Server。访问以下URL以下载SQL Server for x64的ODBC驱动程序:https://go.microsoft.com/fwlink/?LinkId=163712“
还有这个
“[Microsoft][ODBC Driver Manager]未找到数据源名称,且未指定默认驱动程序”
我已经安装了ODBC Driver
就像在这个消息中说的那样。我在我的php.ini
上添加了扩展并重新启动IIS
,但仍然错误。
PHP version: 7.2.
Windows: Windows Server 2008 R2 x64
Sql Server: 2012 express
我的phpinfo PHPInfo
有人能帮我吗
使用的代码(简单的sqlsrv_connect)
$serverName = $this->host;
$connectionInfo["Database"] = $this->banco;
if ($this->user) $connectionInfo["UID"] = $this->user;
if ($this->pass) $connectionInfo["PWD"] = $this->pass;
if ($this->port) $serverName.=', '.$this->port;
$this->id_db = sqlsrv_connect( $serverName, $connectionInfo);
完整错误消息:
array(2) {
[0]=> array(6) {
[0]=> string(5) "IMSSP"
["SQLSTATE"]=> string(5) "IMSSP"
[1]=> int(-49)
["code"]=> int(-49)
[2]=> string(189) "This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712"
["message"]=> string(189) "This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://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"
}
}
1条答案
按热度按时间tzcvj98z1#
Double check versions of drivers以确保它们可以一起工作。事实证明-这是非常重要的。
如果您使用
ODBC Drivers
的良好版本来使用PHP sqlsrv
,请在此处检查。对于PHP 7.2和sqlsrv-5.8.1,您需要使用Microsoft ODBC 17
如何安装它的更多信息在MS文档站点here上
对于
RHEL
: