如何将PHP 5.5.x或更高版本连接到wamp中的mssql 2008 R2? 版本: php:5.5 编译器:MSVC11 架构:x86 胎面安全:已启用
我尝试了以下步骤: 1.尝试连接sqlsrv_connect() 下面的示例代码(test-connect.php):
<?php
$serverName = "192.168.1.5";
$connectionInfo = array( "Database"=>"testDB", "UID"=>"sa", "PWD"=>"sa123");
$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));
}
?>
当我运行文件test-connect.php时,它抛出以下错误:
**"Fatal error: Call to undefined function sqlsrv_connect()"**
我尝试将以下两个DLL文件放到PHP ext文件夹中 a)php_pdo_sqlsrv_55_nts.dll b)php_sqlsrv_55_nts.dll
并使用以下扩展程序更新了php.ini 延长= php_sqlsrv_55_ts.dll 延长= php_pdo_sqlsrv_55_ts.dll
重新启动所有服务
仍然低于给定错误: -
**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 ) )**
任何人都可以帮我解决这个问题吗?这是Apache / PHP版本的问题吗?
答案 0 :(得分:0)
基本上你需要安装url在你的错误desc中的库,并把这个库放到php.ini中,有点像这样:
Extension=php_sqlsrv.dll