[PHP] mysql_connect() fails randomly

2003-08-18 Thread Jon Drukman
i've got a library file that i require() in all my scripts.  it starts 
with this line:

$dbh=mysql_connect() or die(mysql connect failed:  . mysql_error());

about 5% of the time, this fails for no apparent reason.  it just prints

mysql connect failed:

with no error message.

there's nothing wrong with the mysql server as far as i can tell.  there 
are tons of available connection slots.

any ideas?

it also happens with mysql_pconnect() too.

-jsd-



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] mysql_connect() fails randomly

2003-08-18 Thread Curt Zirzow
* Thus wrote Jon Drukman ([EMAIL PROTECTED]):
 i've got a library file that i require() in all my scripts.  it starts 
 with this line:
 
 $dbh=mysql_connect() or die(mysql connect failed:  . mysql_error());


The problem is the mysql_error() cant display what the problem is
because the connect failed. (this needs to change in the docs.)
Here is what you can do to get an error message of why it failed:

  . Ensure your error_reporting level is high enought to allow
  Warnings, and make sure display_errors is on.

  or

  . Turn on track_errors and use the variable $php_errmsg inplace
  of mysql_error().

die(mysql connecte failed: $php_errmsg);

HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php