好的。如果我有头发,此时一切都将放在地板上。我在笔记本电脑和工作机上都具有相同的文件,并且完全没有问题(当然)。两天前,我将其放在另外两台计算机上,并收到以下错误。从那时起我一直在研究和战斗。
我已经测试了odbc和pdo_odbc,但是那里也没有运气。
我敢肯定这是愚蠢的,但是任何帮助都将不胜感激。
先决条件:
:
<?php
$serverName = "Agency"; //serverName\instanceName
$connectionInfo = array( "Database"=>"Dashboard_DB", "UID"=>"uname", "PWD"=>"pword");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
?>
我明白了:
Connection could not be established.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x86: https://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x86: https://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 ) )
我在结果中尝试了链接中的文件,但结果仍然相同。
这是PHP.ini扩展部分
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
;extension=exif ; Must be after mbstring as it depends on it
;extension=mysqli
;extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
extension=php_pdo_sqlsrv_72_ts_x64
extension=php_sqlsrv_72_ts_x64
;extension=php_pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop
答案 0 :(得分:1)
在您的服务器中,您检查了PHP的文件夹扩展名是否具有正确的文件.dll?
驾驶员可能还需要Microsoft® ODBC Driver 11 for SQL Server® - Windows或Microsoft® ODBC Driver 13 for SQL Server® - Windows + Linux才能工作
如果您没有.dll,则可以下载并安装(安装程序仅将.dll提取到目标文件夹中)Microsoft Drivers 5.2 for PHP for SQL Server 到文件夹“ PHP / ext”
在System Requirements for the Microsoft Drivers for PHP for SQL Server处,您将看到相应的驱动程序