doutanggun9816 2011-10-04 15:51
浏览 287
已采纳

使用PHP中的PDO_MSSQL连接到SQL Server

I have a problem while trying to connect to my SQL Server 2000 database using pdo_mssql with this line:

$connection = new PDO ('mssql:host=localhost;dbname=DNAME', 'user', 'password');

The exception is the following:

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 

If I make the connection using the function mssql_connect() as follows, I obtain no error and my connection is correctly made:

$link = mssql_connect ('localhost', 'user', 'password');

Any idea? Where can I read the detailed error message? Thanks

  • 写回答

1条回答 默认 最新

  • dongweihuan8832 2011-10-04 16:14
    关注

    My database name had the character "-", removing it solved the problem!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug