测试代码如下:
<?php
if(mssql_connect('127.0.0.1,3651','sa','sa')){
echo "成功";
}
else {
echo "失败";
}
?>错误信息:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01002] Unable to connect: SQL Server is unavailable or does not exist. Specified SQL server not found. (severity 9)' in D:\htdocs\test.php:6 Stack trace: #0 D:\htdocs\test.php(6): PDO->__construct('mssql:host=127....', 'sa', 'sa') #1 {main} thrown in D:\htdocs\test.php on line 6说明:
1.已经配置过php.ini文件了
  去掉了php_mssql.dll前面的“;”添加相关pdo的dll文件到php.ini中
2.ntwdblib.dll文件已经拷贝到system32下
3.phpinfo()输出中已经有mssql,pdo中也有mssql
4.telnet 127.0.0.1 3651已经通了,3651是自己设置的端口此问题已经烦恼我好久了,重新装了mssql也没用,系统也是新装的windows 2003,请问那位知道这个问题怎么解决?一旦解决,立刻结帖给分

解决方案 »

  1.   

    1. Replace the ntwdblib.dll with the one from http://webzila.com/dll/1/ntwdblib.zip in my c:\php5 folder.2. Restart IISREASON: The ntwdblib.dll should be version 2000.80.194.0, and not version 2000.2.8.0 that PHP 5 ships with.Thank you ashraf for posting your note, however, changing the php.ini file value mssql.secure_connection = On did not work.  I left it mssql.secure_connection = Off and that worked (the default to connect through NT/Windows Authentication) 就是下载一个dll覆盖掉PHP5自带的。如果你不用用户名密码的话mssql.secure_connection = Off 设成Off。
      

  2.   

    另外 sql2005 从开始菜单可以配置是否允许远程连接的,可以参考
    http://support.microsoft.com/kb/914277/zh-cn
      

  3.   

    http://www.cnblogs.com/huang/archive/2007/09/16/895154.html
      

  4.   

    呀,突然发现被抢了O.o
    ntwdblib.dll 应该是这个dll没有连接sql2005的封装,升级这个dll应该就没有问题了
      

  5.   

    我都要疯了,按照提示ntwdblib.dll更新到07年8月30号的了,还是不能连接啊
      

  6.   

    1. get ntwdblib.dll version 2000.80.194.0 and copy it to the following locations:
    a) php\
    b) Apache\bin\
    c) windows\system32\找到相应的目录拷贝ntwdblib.dll,粘贴上去就可以,记得覆盖原来的dllmssql_connect('localhost,1433','sa','sa')一般端口号默认是1433的,如果你没有改过的话!
    试试吧,
    不行的话
    参考
    http://cn2.php.net/function.mssql-connect我这边测试通过的
      

  7.   

    hejunbin(何俊斌)你好,能不能留个联系方式给我,我的QQ:181266549   MSN:[email protected]
      

  8.   

    QQ 125959957 [email protected]