corsonr
7/24/2012 - 9:11 AM

create a custom database error page

create a custom database error page

<?php
	// Tell Search Engine
	$protocol = $_SERVER["SERVER_PROTOCOL"];
	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0';
	header( "$protocol 503 Service Unavailable", true, 503 );
	header( 'Content-Type: text/html; charset=utf-8' );
	header( 'Retry-After: 600' );
	
	// Get Variables
	$temp = mysql_error();
	$url = curPageURL();
	
	// Get Page URL
	function curPageURL() {
		$pageURL = 'http';
		if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80") {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		
		}
		return $pageURL;
	}
	
	// Send The Alert
	mail( 'your@mail.com', 'SQL Error on my Website', 'This is an automated message, there is a SQL error, here is the message : '.$temp.'. Current URL is : '.$url);
?>

<html>
<head>
    <title>The website is down</title>
    <style>
        body { background: #FFFFFF ;font: 16px verdana, serif; line-height: 1.3; margin:0; padding:0; }
        #wrapper { height: 225px; margin: 80px auto 0; width:575px; }
        h1 { font-size: 34px; font-weight: normal; margin-top: 0; }
        p { margin: 0 0 10px 5px; }
    </style>
</head>
<body>
    <div id="wrapper">
        <h1>The website is currently down</h1>
        <p>An alert has been sent to the webmaster, please try again in 10 minutes.</p>
    </div>
</body>
</html>