PHP Adaptive Server connection failed (severity 9)

2019-07-30 17:10发布

问题:

I'm trying to connect to microsoft SQL server 2008 my application is running on a linux server and I have the dblib pdo driver installed. I used port forwarding to connect thru port 1433. I keep getting this message:

SQLSTATE[01002] Adaptive Server connection failed (severity 9);  

PHP:

$connect = new PDO('dblib:host=ipaddres:1433;dbname=namedb','username','password');

回答1:

I suggest to test DB connectivity w/ tsql in this way : tsql -H server_address -p 1433 -U user -P pass -D dbname

in my case I found that simply "Reason: The password of the account has expired" PDO gave me a strange error while tsql gave me the right error.



回答2:

I got the same problem when rewriting a script from mssql_ functions to pdo. I noticed that the old code did not have a mssql_select_db, but i used dbname in pdo. When i removed the dbname parameter the connect worked.