Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
if($conn)
{
    echo "works";
}
else 
{
    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
fails

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

All constructive input is appreciated.

Thanks

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

1 Answer 1

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

 
discard

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.