Home  >  Article  >  Backend Development  >  PHP连接MSSQL数据库异常 急

PHP连接MSSQL数据库异常 急

WBOY
WBOYOriginal
2016-06-13 13:45:00868browse

PHP连接MSSQL数据库错误 急急急急
我用mysql_connect()连接MySql数据库正常,但是用mssql_connect()连接不上,提示不能连接到数据库。用PDO连接同样连接不上。之前我用C++做的一个程序连接我的SQL SERVER一切正常,请问是什么原因呢,求解释啊,急急急

我把我的PDO连接和错误代码都挂上,方便高手解答,万分感谢
$dbh = new PDO('mssql:host=localhost;dbname=MyData','sa','*****');//密码已隐藏
就这一句代码,连接不上,错误提示是:
'SQLSTATE[01002] Unable to connect: SQL Server is unavailable or does not exist. Access denied. (severity 9)'

------解决方案--------------------

探讨

引用:

SQL Server Configuration Manager

恩,谢谢,用那个连接是成功的
我找到问题了,使用mssql_connect的时候,那个servername,不可以用localhost,127.0.0.1,用这个都显示找不到服务器,换成计算机名称就好了,晕,耽误我半天了
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn