Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 mssql - php connection - Intermittently Connects??

Author  Topic 

redherring
Starting Member

12 Posts

Posted - 2008-02-26 : 17:49:04
We have created some very simple php pages to see if the code can retrieve data from our SQL Server, and they do successfully query the database and return data, BUT, only about 2 out of 10 times on a browser refresh. The rest of the times we get a "Unable to connect to server: localhost,1433" error.

This, of course, has us very confused. I'd almost rather not be able to connect at all as it would make more sense.

Since the page does return results sometimes, albeit infrequently, it would not seem to be a php issue, per se.

If you are able to provide any insight into what might be happening with our setup, it would be MUCH appreciated. We are running MSSQL 8.00.818, PHP Version 5.2.5, and IIS 6, all on the same box.

Thanks in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-26 : 17:56:28
First, try to install SP4 for SQL Server 2000.
Then post your connection string here.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

redherring
Starting Member

12 Posts

Posted - 2008-02-26 : 18:07:56
Hey Peso -

Thanks for the reply.

If this is a recommended course of action, then I will give it a whirl. If it's more of a "try this" kind of thing, then I'd rather not only because there's a lot more stuff that "works" now than doesn't, and I'd hate to somehow break more.

Any thoughts... should SP4 be relatively painless?

Thanks.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-26 : 18:10:13
SP4 contains many bugfixes since initial release. It seems like good idea to keep your server as updated as possible.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-26 : 22:10:13
Tried connect with real sql instance name instead of localhost?
Go to Top of Page

redherring
Starting Member

12 Posts

Posted - 2008-02-26 : 22:58:17
Hi there -

Thanks for your comment. Yes, I have tried it spec'ing the instance name vs. localhost.

The fact that the function does return results sometimes, albeit infrequently, is either a very helpful (to the right person) or a very confusing clue...
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-02-26 : 23:02:49
Is dns stable? Tried connect with ip address and port number?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-27 : 01:54:43
Do you get any error?
What do the function return when "not returning results"?
In SP4 there are fixes for function returning NULLs when it shouldn't, and vice versa.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

redherring
Starting Member

12 Posts

Posted - 2008-02-27 : 09:07:00
Hi Peso -

This is the error I get whenever I don't get a proper result (again, it's about 1 or 2 times out of 10 that the page loads properly):

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost,1433

Here's my connection string:

$hostdb = 'localhost,1433'; // MSSQL host
$userdb = 'username'; // MSSQL username
$passdb = 'password'; // MSSQL password
$namedb = 'database'; // MSSQL database name

$link = mssql_connect ($hostdb, $userdb, $passdb);

Man, I sure don't want to port this application to mySQL but I'm running out of options.

Thanks.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-27 : 11:13:25
Have you tried using connection pooling?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

redherring
Starting Member

12 Posts

Posted - 2008-02-27 : 11:47:57
Peso -

Wow... I am not quite sure how to thank you, as what you have suggested seems to have worked!

mssql_pconnect vs. mssql_connect

While I'd love to know the "why" of it, I am ecstatic for now that things seem to be working.

Thank you, thank you, thank you!
Go to Top of Page
   

- Advertisement -