【问题标题】:mssql_connect(): Unable to connect to server on windows server 2000mssql_connect():无法连接到 windows server 2000 上的服务器
【发布时间】:2016-04-12 07:12:00
【问题描述】:

我有 php 的应用程序。我想在 sql server 2000 上连接

这是我的代码:

$server = '10.0.0.26';

// Connect to MSSQL
$link = mssql_connect($server, 'username', 'password');

if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}

但我有类似的错误

消息:mssql_connect():无法连接到服务器:10.0.0.8。一世 确保我使用正确的用户名、密码和 ip。

当我使用此代码连接 sql server 2012 时。我没有收到任何错误。

我在 linux 上使用 apache 运行我的 php。

【问题讨论】:

    标签: php sql-server


    【解决方案1】:

    第一个参数应该是 SERVERNAME 而不是服务器的 IP,因为它在 PHP DOCS 中提到

    例如(来自 php 手册)

    $server = 'KALLESPC\SQLEXPRESS';
    
    // Connect to MSSQL
    
        $link = mssql_connect($server, 'sa', 'phpfi');
    
        if (!$link) {
            die('Something went wrong while connecting to MSSQL');
        }
    

    【讨论】:

      【解决方案2】:

      检查您的 php.ini 文件:

      ; Use NT authentication when connecting to the server
      mssql.secure_connection = On
      

      如果您有secure_connection = On,请确保您在系统服务框中的Apache 服务属性中提供有效凭据。那么您不应该将脚本中的数据库用户名和密码发送到 MSSQL Server。

      如果您想使用 PHP 脚本中的特定凭据,请设置

      mssql.secure_connection = Off 
      

      在你的 php 脚本中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-10-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-21
        相关资源
        最近更新 更多