Connecting to SQL Server with PDO_MSSQL in PHP

I have a problem when trying to connect to my SQL Server 2000 database using pdo_mssql using 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 create a connection using the mssql_connect () function as follows, I get no error and my connection is done correctly:

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

      

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

+1


source to share


1 answer


There was a "-" character in my database name, removing it, solved the problem!



+1


source







All Articles