note 12000 added to function.mysql-connect.php
| From: | webmaster at trafficg dot com | Date: | Sat, 17 Mar 2001 03:35:46 +0000 |
| Subject: | note 12000 added to function.mysql-connect.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12495@lists.php.net to get a copy of this message | ||
if your database connection normally works fine and occasionally you receive a message such as
Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (111) in connection.inc.php on line 5
Then you could try giving this code a try.
$con = 0;
while(!$con)
{
$con = @mysql_connect("localhost", "username", "password");
}
}
The @ character will supress error messages and the while will keep the code trying to connect to
the database. If the database is offline for a extended period of time the script will time out
after 30 seconds or so.
Pete Kelly
http://www.php.net/manual/en/function.mysql-connect.php