mssql_connect():无法连接到服务器

Ehp*_*han 2 php sql-server

我有Apache和PHP就可以了Centos的服务器,我有另一台服务器上的SQL Server中,当我尝试连接到MSSQL带有tsql -H"SQL服务器IP" -p1433 -U sa,它的工作原理,并连接好了,但是当我尝试运行下面的PHP代码

error_reporting(E_ALL);
ini_set('display_errors', '1');
$connection = mssql_connect('serverIP', 'username', 'password');
Run Code Online (Sandbox Code Playgroud)

我收到错误:

警告:mssql_connect():无法连接到服务器:第4行的/var/www/html/mssql.php中的serverIP

我该怎么办?

Mih*_*hai 6

您必须在此示例中指定servername和instance,我认为:http: //ca3.php.net/manual/en/function.mssql-connect.php

编辑:以下方法:服务器\实例不能在unix系统上工作...

实例只是不同于1433的特定端口地址...所以只需发现mssql服务器上的端口,然后尝试使用以下连接:

IP:端口

在unix中,端口由以下内容指定:not by,