我安装了电脑sql server 2005
和其他计算机安装xampp v3.2.1
我尝试通过php在计算机安装xampp中连接到sql server 2005但不能正常工作。
在计算机安装xampp我做:
我从http://www.microsoft.com/en-us/download/details.aspx?id=20098
下载驱动程序3.0 for php我将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。感谢
答案 0 :(得分:0)
检查错误消息,其中显示“此扩展程序需要Microsoft SQL Server 2012 Native Client”。客户端是您安装的额外软件,您可以从Microsoft下载安装程序。
我不确定这是否适用于SQL Server 2005?