If you run WordPress for your site, chances are that every now and then, the following delightful message shows up.
"Error Establishing a Database Connection!"
Gosh, I hate that, don't you?
Well, given that not everyone knows you can reload a page and possibly grab that connection back, *my* site says:
Neat, eh?
Here's how I did it – it's easy, it's free, and I'll give you the file you need at the end!
Step 1.) Create the file db-error.php in your /wp-content/ .
You can use your domain control panel to do this.
Step 2.) In said file, put this:
<?php // custom WordPress database error page header('HTTP/1.1 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable'); header('Retry-After: 600'); // 1 hour = 3600 seconds // If you wish to email yourself upon an error // mail("your@email.com", "Database Error", "There is a problem with the database!", "From: Db Error Watching"); ?> <!DOCTYPE HTML> <html> <head> <title>Database Error</title> <style> body { padding: 20px; background: white; color: black; font-size: 40px; } </style> </head> <body> <center> Alas, might you please reload this page? Sometimes the Universe likes laughing at mortals like ourselves... </center> </body> </html>
Your custom message goes between the red centers.
Step 3.) Save the file, and voila!
Whenever your WordPress has trouble connecting to the database, your custom message will show up.
You can encourage reloading, you can include a marketing message…whatever works best for *you*.
Neat, eh?
Need the full file? Click here for db-error.txt and simply rename it to db-error.php . 🙂
Knowing how to stand out from the rest of the thundering herd is a key component for your 2012 income's fitness. To get similar secrets, check out the latest edition of Income Fitness below.
You'll love what you discover.
Grow strong,
Barbara Ling