在Windows上的PHP 5.5.3中忽略了freetds.conf

时间:2016-07-01 09:13:39

标签: php windows freetds mssql-jdbc

我按照以下链接:https://docs.moodle.org/23/en/Installing_MSSQL_for_PHP在Windows 64bit上的PHP 5.5.3中成功安装了php_dblib.dll(它为Windows 64bit编译的FreeTDS)。 phpinfo()的输出显示:

Environment

...
FREETDS d:\portable_sw\php-5.5.30-Win32-VC11-x64\conf
...
mssql

MSSQL Support   enabled
Active Persistent Links 0
Active Links    0
Library version FreeTDS
...

看起来像PHP引擎捕获freetds.conf并安装了mssql库。在我的freetds.conf中,我已经定义了一个服务器名称' mydb'为:

[mydb]
    host = 10.18.1.11
    port = 1433
    client charset = cp950
    tds version = 7.0

但是当我在浏览器中使用以下php语句运行PHP脚本时:

$conn = mssql_connect('mydb', 'myuid', 'mypwd') or mydie('open mydb failed!');

它只挂了一会儿然后浏览器显示:

Cannot connect to the website

Please make sure: 

- You have entered the correct URL. 
- You are connected to the Internet.
- Your firewall is properly configured.
- The website is not encountering any technical problem at the moment.

Error code 101 (net::ERR_CONNECTION_RESET)

如果我改变了mydb'到' 10.18.1.11',它连接好了。看来freetds.conf中的设置被忽略了。可能是什么原因以及如何解决?

1 个答案:

答案 0 :(得分:0)

我放弃mssql- *并使用sqlsrv- *,它运作良好。所以他的问题由我来回答。