mssql_connect():无法连接到windows服务器2000上的服务器


mssql_connect(): Unable to connect to server on windows server 2000

我有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。

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

eg(来自php手册)

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

检查php.ini文件:

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

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

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

mssql.secure_connection = Off 

在php脚本中。