WordPress 2.3+ official support for custom database error page
Some time ago a tutorial was posted on 5ThirtyOne which addressed customizing the DB Error page rendered whenever visitors landed on heavily trafficked WordPress site. Since then, the method has been proven "useless", ushered away by recent updates to the WordPress code base; more specifically with the release of WordPress 2.3.2 (current release is 2.3.3). Whereas the previous method required manipulating code within a core WordPress file, the new updated method allows for the custom page to be stored externally of the WP root directory. To get started creating your own custom WordPress database error page, follow the two steps below:
Create a db-error.php file in /wp-content/
First things first. Create an XHTML file called db-error.php and upload it to the WordPress /wp-content/ directory.

Because visitors will see this page when your WordPress driven website is experiencing database connection errors, you will need to make sure the file includes any style attributes inline, or reference an external stylesheet (absolute URL).
<style type="text/css">...your CSS goes here...</style>
or
<link href="http://url.com/my-stylesheet.css" rel="stylesheet" type="text/css">
For the sake of simplicity, we’ll create a custom database error page with a single XHTML document including any style attributes inside the <head> tags. The following is the message skeleton originally created and used in the tutorial here.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>My server crashed, please call the next of kin</title>
<style type="text/css">
body {
font-family: arial, verdana, sans-serif;
font-size: 62.5%;
background: #fff;
color: #333;
text-align: center;
}
a {
text-decoration: none;
outline: none;
}
#error_wrapper {
font-size: 1.3em;
margin: 5em auto 0;
text-align: left;
width: 333px;
}
.content_wrapper {
padding: 1em 0.7em 0;
}
</style>
</head>
<body>
<div id="error_wrapper">
<div class="content_wrapper">
<p>It looks as though my server has taken an unsupervised leave of absence. I may not know of its whereabouts so would you be so kind as to notify me via <a href="mailto:admin@domain.com" title="Send me an email">email</a>?</p>
</div>
</div>
</body>
</html>
Second step, there is none
If you created a standard XHTML document and dropped the code in db-error.php inside the /wp-content directory, there really isn’t anything else to do other than to ensure that your site visitors never see a WordPress database error page while visiting your site.
Explore » Discover new content on 5thirtyone.com
This post tagged custom, database, db-error.php, error, WordPress. Explore similarly tagged content below or visit a random entry. Visit the archives for additional content.












Jonathan Solichin
53m1.com
That’s pretty cool. Of course, those who are uninformed will just blame you for having crappy hosting and using Wordpress anyway. But it’ll still be cool to have a different kind of error than the usual. Another way to remind people of you
Feb 11th, 2008 Quote
Neil
dotneil.com
Now that’s handy; I didn’t even know the error DB page was essentially hard-coded into the WordPress core (and, therefore, a clean slate at every update).
Now I just need the traffic with which to bring my database to it’s knees, and to give my DB error page a chance to show itself to the world!
Feb 12th, 2008 Quote
milo
3oneseven.com
Every time I come here, I am learning something new, thanks Derek.
Feb 16th, 2008 Quote