我有一台计算机安装sql server 2005
和其他计算机安装xampp v3.2.1
我尝试通过计算机安装 xampp 中的 php 连接到 sql server 2005 但无法正常工作。
在计算机上安装 xampp 我做:
我从下载驱动程序 3.0 for php我从http://www.microsoft.com/en-us/download/details.aspx?id=20098
我复制了 2 个文件php_sqlsrv_54_ts.dll
,然后php_pdo_sqlsrv_54_ts.dll
将Xampp\php\ext
下面的代码添加到 php.ini
[sqlsrv]
sqlsrv.LogSubsystems=-1
sqlsrv.LogSeverity=-1
sqlsrv.WarningsReturnAsErrors=0
extension=php_sqlsrv_54_ts.dll
extension=php_pdo_sqlsrv_54_ts.dll
我通过以下方式测试连接
$serverName = "nameserver";
$connectionInfo = array("Database"=>"namedatabase");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn) {
echo "success";
}else {
die (print_r(sqlsrv_errors(),true));
}
但我得到错误
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 ) )
如何从 php 连接到 sql server。谢谢