1

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

j0k
  • 22,600
  • 28
  • 79
  • 90
Joaquín L. Robles
  • 6,261
  • 10
  • 66
  • 96

1 Answers1

1

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

Joaquín L. Robles
  • 6,261
  • 10
  • 66
  • 96
  • Same problem here... but cannot remove "-" from database name. Tried connection on another DB and works very well. – NBPalomino Oct 06 '15 at 15:51