PHP连接到MS SQL.适用于工作站,但不适用于2台服务器



好的。如果我有头发的话,此时头发都会掉在地板上。我在笔记本电脑和工作机器上都有相同的文件,工作起来一点问题都没有(当然(。我两天前把它放在另外两台机器上,得到了下面的错误。从那以后,我一直在研究和战斗。

我已经测试了odbc和pdo_odbc,但也没有运气。

我确信这是件愚蠢的事,但如果有任何帮助,我们将不胜感激。

前提条件:

  • PHP 7.2.5
  • MS-sql2008r2
  • Windows Server 2008 R2 SP1 64位

:

<?php
$serverName = "Agency"; //serverNameinstanceName
$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

在您的服务器中,您检查了PHP的文件夹扩展名是否有正确的文件.dll?

驱动程序可能还需要用于SQL Server®-Windows的Microsoft®ODBC驱动程序11或用于SQL Server™-Windows+Linux的Microsoft®ODBCDriver 13才能运行

如果你没有.dll,你可以下载并安装(安装程序只提取目标文件夹中的.dll(Microsoft Drivers 5.2 for PHP for SQL Server到文件夹"PHP/ext">

在这里,您将看到适用于SQL Server的Microsoft驱动程序的系统要求

最新更新