Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running mssql_connect on a local machine

Status
Not open for further replies.

Guggly

Programmer
Joined
Jan 18, 2004
Messages
110
Location
US
Hi! I'm running Windows 2000 with MS SQL Server Desktop Engine installed along with the client components from the full product. On this same computer I’m running my web server (IIS) and PHP.

I need to access MS SQL from PHP and this was working fine when I was running the SQL server on a Windows 2000 server machine. However, when I change the server name in my script I'm getting the PHP error: "Warning: mssql_connect(): Unable to connect to server: mike..."

I've tried every combination possible for the server name, including the machine name (mike), machine IP address, "localhost", "127.0.0.1", and combinations with the SQL port (I've verified that my SQL setup is listening on port 1433). What seems odd to me is that this was working perfectly when I was connecting to MSSQL on the server, but locally it's not working at all.

I know that there's not a problem with my SQL Server setup because I can use the database fine from both MSAccess and SQL Enterprise Manager. It's also not an authentication issue because my logon (SA) and password are correct, and I'm not getting an authentication error for that matter. Any clues as to what might be causing the problem?

Thanks! – Mike

Code:
//Connect string that worked to access the server:
$link = mssql_connect("server", "sa", "*****") or die("Could not connect");

//Connect string that isn't working locally:
$link = mssql_connect("mike", "sa", "*****") or die("Could not connect");
 
Is there a DSN called 'Mike' that points to the server? PHP is looking for the DSN not the machine name...
 
Nah, that "mike" is my computer name.

So, the "string servername" needs to be a DSN? What if you're not accessing the database through ODBC?
Also, why did it work fine when I was using the "server" machine name. I don't have a DSN defined with that name?

BTW, I can connect fine to a local MySQL database using "localhost" and mysql_connect. I guess it's different with MSSQL?

Thanks for your help -- Mike
 
Searching online a bit more, it seems that maybe this is a problem with PHP not supporting MSDE correctly? I found a few posts with the same problem as I describe above, but only one post with someone saying that they were able to connect to MSDE succesfully from PHP.

Anyone know for sure? Thanks! -- Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top