What's with all the pink?

Find out more at Pink for October or get your own Pink!

5ThirtyOne

Avatar

A blog. A website. A semi-coherent receptacle for Derek Punsalan mixed with excerpts of technology, personal interests, and noteworthy items.

Twitter: Saigon nightlife... inter-est-ing. Squared, Lush, and Gossip.
Get content delivered: RSS | Email

Derek Punsalan...is Sylvia Loh MyQuire - Get stuff done with people who share your passions Box.net - Access your files anywhere with Box

Current » This post published on June 23rd 2006 at 9:07 pm

Custom WordPress Database Error

UPDATE 12/31: As of WordPress version 2.3.2, users can now easily replace their Database error using wp-content/db-error.php as their error template.

If you’re a longtime WordPress user, you’re probably aware of the Database Error page which rears its not so shiny face whenever your MySQL server decides to take a bathroom break. There’s no shame in enjoying the default error page which comes prepackaged with WordPress. It simple, effective, plain, did I say plain yet? Yes it’s plain.

After noticing that 5ThirtyOne was dead in the water due to server downtime, I decided the default error page had to go.

custom wordpress error page

Fortunately, swapping the default is quite simple and something that I highly recommend to any and all WordPress users. There’s a certain sense of “professionalism” to WordPress sites which customize the smallest details to match their entire site through and through.

Where is the database error template served?

WordPress 2.0+ users can find the necessary lines to edit within ‘/wp-includes/wp-db.php’. Beginning immediately below line 307, paste the following:

/* custom error page hack
shows a custom error page and emails error instead of
showing the default wordpress database error page */
include('wp-content/themes/themename/dbase-error.php');
$error = ( !$this->show_errors ) ? '' : $this->show_errors ;
mail('admin@domain.com', 'WordPress Error', $error);
die;
/* end custom error page hack */

For a hand-holding walk-through of each snippet of code, head on over to All Forces where Melvin breaks down the little stuff. The most important details should be recognizeable above: a) the path to your custom template titled dbase-error.php, and b) the email address that WordPress should notify in case of emergency.

A simple template to get you started

Once you’ve made the appropriate edits within wp-db.php, you can now move on to creating a suitable error page to match the look and feel of your site. Below I’ve shared a little sample of code to get you started. Feel free to download a physical copy of dbase-error.php for upload.

<!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%;
line-height: 1.7em;
background: #fff;
color: #333;
text-align: center;
}
a {
text-decoration: none;
outline: none;
}
#error_wrapper {
font-size: 1.3em;
margin: 2em 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>

I’ve chosen to embed the CSS for the sake of convenience. If your error page begins to get a little disorganized, moving your stylesheet to an external source may be a more suitable route. Make note that all references to files within WordPress must be absolute paths.

Show me yours

Now that you have a clean canvas to work with, show me what your database error message will be. Being that errors are few and far between, I’ve pasted mine below:

Unfortunately, it seems that 5ThirtyOne is suffering from a database error which prevents this WordPress driven site from delivering the content which you so desperately seek.

Rest assured that the lemmings living within the servers are hastily working to restore the MySQL database making everyone - especially me - a little less irritated.

If you feel the need to speak to me on a more personal level, I invite you to drop me an email at derek@5thirtyone.com.

If I broke my own site on accident, I really didn’t mean to. Change is good though right?

Let’s try to be original. If there’s one thing worse than copying someones ‘About‘ page, it’s copying someones error page. Drop your renditions in the comments.


Explore » Discover new content on 5thirtyone.com

This post tagged , , . Explore similarly tagged content below or visit a random entry. Visit the archives for additional content.

Meta » Gritty post related bits

The post titled Custom WordPress Database Error is categorized under Tutorial. Feel free to leave a comment or trackback from your own site.

Advertisement

Reader Activity: Have something to say about Custom WordPress Database Error?
21 Comments
  1. Great post.. except it’s not much use to me per-say - since moving from dreamhost to (mt) I’ve not actually experienced an outage.. MySQL or otherwise. :)

  2. Better safe than sorry. You never know. Besides, having a matching error page to boot is nice for those rainy days. Look at me. Today alone I purposely misconfigured WordPress just so the database error would display. How bad is that?

  3. Today alone I purposely misconfigured WordPress just so the database error would display. How bad is that?

    Heh, I’ve been known to do such things to test an idea. Seriously though it amazes me how bad DH has got.. it used to be great.

    Like I said - it’s a great idea.

  4. Heh, I’ve been known to do such things to test an idea. Seriously though it amazes me how bad DH has got.. it used to be great.

    Dh isn’t that bad. Come on now. I’m still holding out from switching over to Media Temple despite having joined 9rules.

  5. Well, it’s prettier than your 404 Derek, which folk are likely to see more often:

    “Parse error: syntax error, unexpected T_ENDIF in /home/.ghostbuster/f5thirtyone/5thirtyone.com/wp-content/themes/reboot/404.php on line 14″

    I did customize my 404, which was fun for a few moments.

  6. Wow. Thanks for the reminder that I needed to get the 404 page kicking again. :p All fixed. Unfortunately it doesn’t compare to your 404 Bruce.

  7. Ah nice, since I can’t leave anything alone I will have to whip up something! ;-)

    Not to turn this post into a hosting discussion, but I haven’t had any of these downtime problems with (mt) ;-) I have had ftp crash on me a couple times but that is about it. Go MT!

  8. Very nice idea, Derek, and a clear explanation of what to do to turn on the custom error page. I especially like the idea of embedding the CSS - error pages I’ve had on a commercial site I once ran sometimes had difficulty finding stylesheets, although I see now that the path should have been hardcoded in there.

    If you look at the Apple error pages they’re just delicious - don’t you think?

  9. Apple definitely has one of the more style error pages that I’ve seen online. Despite what some may believe, the 404 and error pages are one of the more important elements of a website.

  10. I hate to admit this, but I’ve been known to put in some silly page names just to see the Apple 404’s.

    But then again the whole of the Apple site makes me want to dive in and spend time there, ever since I became a Mac convert a few years ago after two decades of pc ownership.

    I still use pc for business, but for my stuff it’s all Mac. I have the new Macbook which is - as Americans say - fine. Went a little bit off-topic there!

  11. I think there’s a little bug in the script. Shouldn’t the script send an email with some useful information instead of the show_errors boolean? I believe this is better:

    $error = ( !$this->show_errors ) ? ” : $message ;

    –nico

Leave a Reply

Your comment may be held for moderation. If your comment is not displayed immediately, do not repost. I reserve the right to remove any and all comments deemed as personal attacks or completely off-topic. Please use the appropriate discussions forum if your comment is not applicable to the current article.

Archived: Browse previous activity by category
Browse an overview of recent activity

View Tutorials » Step-by-step go make something tutorials

WordPress Custom Fields; laying text over your lead graphic

For WordPress users, there are certain scenarios when the typical reverse chronological presentation of content is just not enough. I have experimented with different methods ...

Remove DRM protection from iTunes tracks with iMovie HD

A few days back I found myself perusing the iTunes Music Store looking for a few songs that I had heard via Sirius*. After completing ...

View Apple » Apple software & hardware related articles

"What you’ll find in my Leopard"… and what you won’t

I had made plans for a proper break-down concerning the features, changes, and updates for Apple's latest feline incarnation - 10.5 Leopard. Ultimately, I decided ...

How-to: Proper Gmail IMAP for iPhone & Apple Mail

UPDATE 11/18: inaequitas reminds us that in order to star messages on your iPhone, simply move the message the starred items directory. UPDATE 10/26: RayL re-confirms ...

View Personal » Personal thoughts & rants

Planning on carrying the momentum, 2007 to 2008

Syl caught a photo of Boo (Mini Rat Terrier) in a rare "not bouncing off the wall and couch" mode The later part of 2007 was ...

November is purple, Pancreatic Cancer Awareness

Educate and promote awareness Last month 5ThirtyOne went pink to support Pink for October raising awareness for Breast Cancer Awareness Month. A co-workers partner raised the ...

View Inspiration » Design related announcements & articles

Lovely Blogs highlights "blog design"

Ben Bleikamp, also known for his entrepreneurship blog College Startup, has been hard at work coding and compiling his design community share Lovely Blogs. Now ...

Rebooted - “Fat” faux footers

Inspired by Phu's Many colours of a reboot, I've decided to share my favorite sites which utilize "fat" footers. I think the more appropriate title ...

View Mobile » Mobile technology & information

Asus Eee PC sub-notebook running Apple OS X

Ignoring the legalities or hair pulling from Apple's legal department, Dan decided that it was high time for a sub-notebook running OS X. If Apple ...

Unlimited SMS savings for iPhone (or any phone) family account holders

There are currently three different iPhone plan add-ons for at&t family accounts. Each plan offers unlimited data usage & visual voicemail. The only difference which ...

View Noteworthy » Take note, noteworthy posts or news

Maybe shopping in person actually does save time?

Yesterday I was hoping to have some free time to visit the grocery store to pick-up a few necessities. Unfortunately, I realized all too late ...

Warning! Gmail users beware, fake upgrade emails

UPDATE: According to a comment on digg, gmailupgrades.com has been taken down. Important FYI update for any Gmail users. If you receive the following email in ...

View Productivity » Staying productive, articles pertaining to productivity

Box.net evolves, say hello to OpenBox

Box, a long-time favorite mentioned in Box.net as a collaborative file manager, has evolved into OpenBox adding new features which would tie the service into ...

Basecamp, activeCollab, and Goplan compared

UPDATE 11/18: activeCollab is no longer offered as a free project management collaboration download. From the design, development, and product strategy company Webreakstuff comes a new ...

View WordPress » Articles pertaining to the rock solid CMS WordPress

The Unstandard WordPress theme

The Unstandard WordPress theme is released / shared with the intent of breaking the typical blog mold. Farewell to the blase reverse chronological text heavy ...

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. ...

Advertisement



External: Your reader says "feed me"
Finished? Return to the top

Flickr » Subscribe to my Flickr

  • Coconut juice
  • Dried fish
  • Fresh crabs
  • Fresh frogs
  • Rooftops
  • Vietnam Airlines