netaustin
3-31-03, 10:43 PM
<?
if(!($link = mysql_connect("yourserver.powweb.com", "user", "pass"))){
$error_one = mysql_error();
if(!($link2 = mysql_connect("localhost", "user", "pass"))){
$error_two = mysql_error();
echo "Could not complete MySQL Connection<br>$error_one<br>$error_two<br>";
}
}
?>
So much traffic in this part of the forum is all about MySQL troubles - so I thought I'd have a go at coding a solution. All you need to do is replace your current call to mysql_connect() with this chunk, wherever it falls, and it will try both methods before failing.
No more rotating from yourserver.powweb.com to localhost!
This way, when the mysql server stops accepting unix socket connections or tcp connections, the other will work. That makes this script useful, because you can never predict which of the two will fail. The only case in which this script won't work is if they both fail.
Note: This will not work with mysql**.powweb.com - you have to use a tcp connection.
if(!($link = mysql_connect("yourserver.powweb.com", "user", "pass"))){
$error_one = mysql_error();
if(!($link2 = mysql_connect("localhost", "user", "pass"))){
$error_two = mysql_error();
echo "Could not complete MySQL Connection<br>$error_one<br>$error_two<br>";
}
}
?>
So much traffic in this part of the forum is all about MySQL troubles - so I thought I'd have a go at coding a solution. All you need to do is replace your current call to mysql_connect() with this chunk, wherever it falls, and it will try both methods before failing.
No more rotating from yourserver.powweb.com to localhost!
This way, when the mysql server stops accepting unix socket connections or tcp connections, the other will work. That makes this script useful, because you can never predict which of the two will fail. The only case in which this script won't work is if they both fail.
Note: This will not work with mysql**.powweb.com - you have to use a tcp connection.