Too many mySQL connections

If you have the situation in mySQL where there is the possibility of large number of connections, you can test for that specific error and then redirect to an different page :

<?php $link = mysql_connect("localhost", "mysql_user",
"mysql_password");
if (mysql_errno() == 1203) {
// 1203 == ER_TOO_MANY_USER_CONNECTIONS (mysqld_error.h)
header("Location: http://your.site.com/alternate_page.php");
exit;
}
?>

Leave a Reply