Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to connect to my local SQL Server 2008 R2 (have also tried it with 2005, same result exactly) with PHP. I'm using PHP 5.1 which still supports php_mssql and mssql_connect().

for some reason PHP just won't find my server, I can connect via ODBC flawlessly an thats fine, but I would like to connect to MSSQL directly.

I have connected PHP to MSSQL a million times on different servers, this one seems to be the only one giving me issue.

I am on a Macbook Pro. I have tried using both Bootcamp and Parallels Desktop in both Windows XP and Windows 7. Is there something problematic with this?

This is my little test code to try and get the connection working.

//define connection garbage
$db['hostname'] = "USER90C6\SQLEXPRESS";
$db['username'] = "user";
$db['password'] = "password";
$db['database'] = "kal_auth";

//connection string
$conn = mssql_connect($db['hostname'], $db['username'], $db['password']);

//does it work? :o
    echo "works";
    echo "fails";

The error this code produces:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:     USER90C6\SQLEXPRESS in C:\xampp\htdocs\test.php on line 9

Is there something seriously wrong with my setup? or am I missing something.

All constructive input is appreciated.


share|improve this question
Have you tried to use an 'IP:port' format for the 'hostname'? – Alex Feb 3 '11 at 13:41

Could be alot of things: like NetBIOS/DNS (unable to resolve USER90C6), SQL Express may not be configured to allow remote connections, could be Windows Firewall running on the USER90C6.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.