MySQL - Detect "Too many connections" error and show alternate web page

If you get a Too many connections error when you try to connect to the mysqld server, this means that all available connections are in use by other clients.
The number of connections permitted is controlled by the max_connections system variable. The default value is 151 to improve performance when MySQL is used with the Apache Web server. (Previously, the default was 100.) If you need to support more connections, you should set a larger value for this variable.

Solution provided by user Rob Williams:

<?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;
}
?>