我正在尝试将我的 PHP 与 SQL Server 连接起来。我必须去现场测试它,所以我正在为笔记本电脑配置必要的设置。在我目前工作的桌面上,连接工作正常。但在笔记本电脑中,它不会连接。这是我正在使用的代码:
$serverName = "server"; //serverName\instanceName
$connectionInfo = array( "Database"=>"DB", "UID"=>"user", "PWD"=>"pass");
$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));
}
我已将 .dlls 放在 ext 文件中,并在 php.ini 中编写了扩展名,但不知何故它仍然无法正常工作。这是我得到的错误:
Connection could not be established.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://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 ) )
任何帮助将不胜感激。谢谢你。