当我尝试使用以下代码建立与MSSQL Server
的连接时:
try {
$c_info = array("Database" => "ddb", "UID" => "sa", "PWD" => "admin123");
echo var_dump(sqlsrv_errors(SQLSRV_ERR_ALL));
$db = sqlsrv_connect('LENOVOWIH\SQLEXPRESS', $c_info); // Make a connection to MSSQL
if($db) echo '\ntrue';
else echo "\nfalse : " . var_dump(sqlsrv_errors());
} catch(Exception $e) {
echo $e . " " . sqlsrv_errors();
}
var_dump(sqlsrv_errors())
发出:
array (size=2)
0 =>
array (size=6)
0 => string 'IMSSP' (length=5)
'SQLSTATE' => string 'IMSSP' (length=5)
1 => int -49
'code' => int -49
2 => string 'This extension requires the ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712' (length=184)
'message' => string 'This extension requires the ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712' (length=184)
1 =>
array (size=6)
0 => string 'IM002' (length=5)
'SQLSTATE' => string 'IM002' (length=5)
1 => int 0
'code' => int 0
2 => string '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified' (length=91)
'message' => string '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified' (length=91)
我已将extension=php_sqlsrv_55_ts.dll
放入php.ini
(\ wamp \ bin \ apache \ apache2.4.9 \ bin \ php.ini)文件中dll
在ext
目录中。我正在使用php版本5.5.12
这可能是什么原因?