【问题标题】:How can i connect PHP 5.5.x or above version to mssql 2008 R2 in wamp?如何在 wamp 中将 PHP 5.5.x 或更高版本连接到 mssql 2008 R2?
【发布时间】:2015-10-25 11:41:57
【问题描述】:

如何在 wamp 中将 PHP 5.5.x 或更高版本连接到 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()"**
  1. 我尝试将以下两个 DLL 文件放入 PHP ext 文件夹 a) php_pdo_sqlsrv_55_nts.dll b) php_sqlsrv_55_nts.dll

  2. 并使用以下扩展名更新了 php.ini 扩展=php_sqlsrv_55_ts.dll extension=php_pdo_sqlsrv_55_ts.dll

  3. 重启所有服务

它仍然抛出以下给定错误:-

**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 版本的问题吗?

【问题讨论】:

    标签: php sql-server sql-server-2008


    【解决方案1】:

    看这里: http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/install-the-sql-server-driver-for-php

    基本上你需要安装库,哪个 url 在你的错误描述中,然后把这个库放到 php.ini 中,像这样:

    Extension=php_sqlsrv.dll
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      • 2013-12-13
      相关资源
      最近更新 更多