为什么我的服务器不使用PHP mssql_connect连接到远程MSSQL服务器?

时间:2022-10-06 10:23:11

I've had to move an app we wrote for a client to a new server and a remote connection I was initiating with PHP mssql_connect has ceased to work. I noticed that PHP wasn't compiled with mssql so I asked the server admin to install it. I can verify that it's now installed via PHP info but I now get a consistent "Unable to connect to server" error from mssql_connect.

我不得不将为客户机编写的应用程序移动到一个新服务器上,而我使用PHP mssql_connect启动的远程连接已经停止工作。我注意到PHP没有使用mssql编译,所以我请服务器管理员安装它。我可以验证它现在是通过PHP info安装的,但是我现在从mssql_connect获得一个一致的“无法连接到服务器”错误。

Here's the very simple PHP script I'm running:

下面是我正在运行的一个非常简单的PHP脚本:

$myServer = "myserver.com:5000";
$myUser = "myusername";
$myPass = "mypassword";

$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer. Error: " . mssql_get_last_message());

I've confirmed that the credentials are still correct but for whatever reason it seems that mssql_connect just isn't doing it's thing. I'm wondering if there's something that the admin has forgotton to do having installed the extension and FreeTDS. Any pointers greatly appreciated! :)

我已经确认了凭据仍然是正确的,但是不管出于什么原因,似乎mssql_connect并没有这么做。我想知道在安装了扩展和FreeTDS后管理员是否忘记了一些事情。任何指针大大赞赏!:)

PROBLEM SOLVED!!!

问题解决了! ! !

After all that it turned out to be the FreeTDS protocol version number as specified in /usr/local/freetds/etc/freetds.conf, line number 13 had to be uncommented. That was it! :)

毕竟这是FreeTDS协议的版本号,在/usr/local/freetds/etc .中指定的conf,第13行必须不注释。这是它!:)

2 个解决方案

#1


3  

After all that it turned out to be the FreeTDS protocol version number as specified in /usr/local/freetds/etc/freetds.conf, line number 13 had to be uncommented. That was it! :)

毕竟这是FreeTDS协议的版本号,在/usr/local/freetds/etc .中指定的conf,第13行必须不注释。这是它!:)

#2


0  

There's a good chance that remote connections are disabled on the server where the server is installed. Have you checked whether you are actually able to connect to the DB server remotely, from the IP address of the webserver that attempts to connect to it? Usually, at least in most shared hosting schemes, the database server only accepts connections from localhost. You'd need to add the IP address of the webserver to a whitelist (usually in the server's configuration) to allow connections from the outside.

很有可能在安装服务器的服务器上禁用远程连接。您是否检查过是否能够从尝试连接到DB服务器的web服务器的IP地址远程连接到DB服务器?通常,至少在大多数共享主机方案中,数据库服务器只接受来自本地主机的连接。您需要将webserver的IP地址添加到白名单(通常在服务器的配置中),以允许从外部连接。

#1


3  

After all that it turned out to be the FreeTDS protocol version number as specified in /usr/local/freetds/etc/freetds.conf, line number 13 had to be uncommented. That was it! :)

毕竟这是FreeTDS协议的版本号,在/usr/local/freetds/etc .中指定的conf,第13行必须不注释。这是它!:)

#2


0  

There's a good chance that remote connections are disabled on the server where the server is installed. Have you checked whether you are actually able to connect to the DB server remotely, from the IP address of the webserver that attempts to connect to it? Usually, at least in most shared hosting schemes, the database server only accepts connections from localhost. You'd need to add the IP address of the webserver to a whitelist (usually in the server's configuration) to allow connections from the outside.

很有可能在安装服务器的服务器上禁用远程连接。您是否检查过是否能够从尝试连接到DB服务器的web服务器的IP地址远程连接到DB服务器?通常,至少在大多数共享主机方案中,数据库服务器只接受来自本地主机的连接。您需要将webserver的IP地址添加到白名单(通常在服务器的配置中),以允许从外部连接。