tags:

views:

98

answers:

4

I'm working on a script in PHP that needs to get some info from a SQL Server database. However, I am having trouble connecting to the database. When i use the mssql_connect() function, it gives me an error and says it cannot connect to the database. However, it gives no reason why. Is there any way to find out why it won't connect? There doesn't seem to be a function mssql_error() or anything like there is with the mysql library.

A: 

Have you tried looking in the Windows Event Log? I am not sure if there will be enough info there, but it may help.

Rob Prouse
Unfortunately i don't have full access to the server, so i can't check the windows event log.
The.Anti.9
+1  A: 

Try to use pdo (http://php.net/pdo). the mssql-extension is a mess.

Instead of '' it returns ' ' for empty strings. It seems to be a bug in ntwdblib that has never been fixed. When I experienced the problem i nearly went crazy...

To get the client connected: Have you activated tcp/ip on the sql-server? On MSSQL 2005 Express it's not activated by default!

chris
Yes, I assume it is activated, we have a huge working system using the database. it's just php that can't access it
The.Anti.9
A: 

I would check your settings for the PHP MSSQL extension, I once had Security enabled and needed it off to access a particular MSSQL server.

jtyost2
A: 

Definately move to PDO, you'll get more benefit in the long run when you want more features in the future.