[英]Connecting to SQL Server with PDO_MSSQL in PHP
尝试通过以下行使用pdo_mssql连接到我的SQL Server 2000数据库时遇到问题:
$connection = new PDO ('mssql:host=localhost;dbname=DNAME', 'user', 'password');
例外情况如下:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] General SQL Server error: Check messages from the SQL Server. (severity 5)' in C:\Inetpub\wwwroot\public\test.php:2 Stack trace: #0 C:\Inetpub\wwwroot\public\test.php(2): PDO->__construct('mssql:host=loca...', 'user', 'password') #1 {main} thrown in C:\Inetpub\wwwroot\public\test.php on line 2
如果按如下所示使用函数mssql_connect()建立连接,则不会出现任何错误,并且连接正确:
$link = mssql_connect ('localhost', 'user', 'password');
任何想法? 在哪里可以阅读详细的错误消息? 谢谢
我的数据库名称带有字符“-”,删除它可以解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.