Tricks

it show cool mysql error page if the connection to mysl is lost
Making Cool Mysql Error Page Using PHP

some times my mysql is down because of for example the server load so i has been generated this code

Benefits

  • it give you cool html/css page if the connection to mysql is lost becuase of for example the user or password is incorrect.
  • It prevents search engines from archiving the current page and this is great becuase its an error page and this by this code:
  • <meta name="robots" content="noindex,nofollow">
  • it tells search engine crawlers how long to wait before trying again, which is the main advantage of using this method. The text on the page can be formatted any way you want, to inform human visitors what the problem is.

demo

http://img14.imageshack.us/img14/5595/19542798.gif

Cautions

Before making any changes to your config.php, save a copy of the original so you can revert to it if necessary.

useage

open your config file and try to modify it with this condition
if (!@mysql_select_db('name',@mysql_connect('host','dbuname','ppass'))) {
include ("noconnection.html");
exit;
}
  • $connect is the mysql_select_db function for example read the config example:config.php [336 B].
  • exit; is working on stop the page after include the html file

Html/Css

use quick view tool:noconnection.html [1.31 KB]

<?php header('Retry-After: 172800'); ?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="robots" content="noindex,nofollow">
<title>Temporarily Closed</title>
<style type="text/css">
<!--
body {
	background: url(background.gif) repeat;
	margin: 5px 5px;
	text-align: center;
}

div.transbox
{
  text-align: left;
  margin: 20% auto 0px auto;	
  width: 420px;
  height: 180px; 
  background-color: #ffffff;
  border: 1px solid black; 
  filter:alpha(opacity=60);
  opacity:0.6; 
  -moz-border-radius-bottomleft: 7px;
  -moz-border-radius-bottomright: 7px;  
}
div.transbox p
{
  margin-left: 30px;
  font-family: "Verdana", sans-serif;
  font-weight: bold;
  color: #000000;
}
div.transbox h1
{
  margin-left: 30px;
}
 
-->
</style>
</head>
<body>

<div class="transbox">
<p><h1>Mysql Error</h1></p>
<p>I can't join to the Specific mysql database.</p>
<p>The mysql is down maybe by server load!</p>
</div>

</body>
</html> 

download

download the config example with the background + noconnection.html example take a look to the files blew

in: » Website Designing » Tricks | Posted on Feb 7th, 2009 | last update on May 30th, 2010 | views 6,128
About the author
i'm moustafa from egypt i love doing one thing 'web programming & designing', This year I've got 19 years old and i'm in the english College of management (in Business Administration part soon)