On Sat, January 27, 2007 12:24 pm, kentozier@xxxxxxxxxxx wrote: > I'm having a sporadic connection problem with MSSQL. I have a php > script which is called by a folder scanning application and sometimes > it can run for hours without problem but other times it will run for > just a few minutes and return connection errors. I tried using > mssql_get_last_message but it always seems to return an empty string. > > I'd like to find out why the connection is failing but in the absense > of error info from MSSQL, it's a bit problematic. Is there a creative > way to actually get error strings back from MSSQL in light of the fact > that mssql_get_last_message basically does squat? > > As a last ditch effort, I could run the connect line in a loop a set > number of times until it succeeds but I would prefer to know why it > fails. > > Can anyone offer suggestions? Since mssql_get_last_message is asking the database for the last error that happened, and since you didn't get a database connection in the first place... I believe that PHP basically "hacks" mysql_connection and mysql_error to cram a decent error message into the return of mysql_error() for when a connect fails, and it's possible nobody did this for mssql yet... [This is a supposition based entirely on Voodoo Debugging and not on actual reading of PHP source code... Though I vaguely recall requesting this feature back in 19-nintey-mumble with PHP 3.0RC2 I think...] You may want to try turning on track_errors in php.ini and see if anything useful appears in $php_errmsg or whatever it is. You could also try examining the logs on the MS SQL Server side of the connection for the time period of the failed connections -- or even increasing whatever internal log level is available there to get more info about what went wrong. If all else fails, you could re-compile PHP with debugging on, and force out some kind of backtrace when it fails, I think... One other note: If you are using _pconnect (or _plogon), and you are using PHP as a Module, you have to configure SQL Server to allow *more* connections than you have MaxChildren in httpd.conf. Actually, you need this for *each* username/password that connects in your web application. A "persistent" connection effectively ends up being tied to the Apache child for its life-time, so anything less than the number of children running is going to be problematic. [That is a gross over-simplification of a persitent connection, but that's how it plays out at a level that's easy to post in an email.] -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php