-4
   $serverName = "172.20.90.100"; 

   // Since UID and PWD are not specified in the $connectionInfo array,
   // The connection will be attempted using Windows Authentication.

   $connectionInfo = array( "Database"=>"correctdb");
   $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));
   }    

这给了我这个错误:

致命错误:在第 23 行调用未定义函数 sqlsrv_connect()

我想知道我应该改变什么来建立连接。

4

2 回答 2

3

sqlsrv_connect()是嵌入在 SQL Server 扩展中的 php 函数。该错误表明您尚未启用它。

您必须启用扩展。手册中描述了这是如何完成的。

于 2013-07-18T20:20:37.927 回答
0
  • 如果您尚未安装 Microsoft Drivers 3.0 for PHP for SQL Server,请从此处安装。

  • 确保您的php.ini:

    extension=php_pdo_sqlsrv_53_ts.dll
    extension=php_sqlsrv_53_ts.dll
    

文档:sqlsrv_connect()

于 2013-07-18T20:23:01.667 回答