Modifying WordPress custom database error connection page

Database connection has a big role when we build using a dynamic webpage. To be more spesific, if we’re using WordPress it’s always a good thing to have our database connection alive. But, for some technical situation, database connection might be dropped. Like or not, this is the situation we might have.
To deal with high-traffic website, there is a WordPress plugin (note: we’re talking about WordPress here) called WP Super Cache. This plugin will help your WordPress installation to deal with major traffic, to keep our site alive e.g. when our site got a massive traffic from site like Digg or Slashdot. When there is a failure on MySQL database connection, there will be a page presented informing about problem on establishing database connection. A page that we want to avoid. The worst thing is that when this ‘temporary’ page is indexed by search engines.

Reading what Derek Punsalan mentioned about custom error database connection page, his updated tutorial is very interesting. I mean, we (actually) can modify that error page into something better. In short, to have a custom page for database connection error page, just create a file called db-error.php and put it under your /wp-content/ directory. That’s it.
I made one. Here are few things I had in mind when I built it (I am using WordPress 2.5 right now).

  • I do not want to tell (exclusively) about the database problem.
  • But, I want to tell visitors that there is something does not run well.
  • I want to keep them informed about this site. So, if search engines/other sites send people to my site — but it is not available — they know that actually they come to a right place.
  • The page should not call any database connection (of course!).
  • Lastly, I want to have a better page.

Anyway, the error message will be shown on a current accessed page. If they’re at the front page, they will have a same page when open a permalink or archive page. To see what happened when this site has a database connection problem, look at the screenshot. Of course, I hope that I do not to display this page.
If you want to use my db-error.php, I’ve uploaded the template file so that you can customize it. Download now (2 Kb).


Comments

4 responses to “Modifying WordPress custom database error connection page”

  1. salam..

    To deal with high-traffic website, there is a WordPress plugin ..

    hehe.. i have no high-traffic website, but iam using WP Super Cache.
    i’ll try.. thank you Bang..

  2. Well, i got no luck dealing with WP-Cache or Super Cache plugin…when i install WP-Cache, my WP crashed peacefully, made me have to delete the plugin manually through FTP, and restore the WP-Config.php file… :(
    But thank you for the tips :D

  3. adien, me too. I do not have WP cache-related plugins here right now. The custom error page I mentioned here is just an alternative when something goes wrong with database connection even it is related to traffic or not.
    gagahputera, I think you’re unlucky then… Or, probably you do not need that plugin right now… :)

  4. nice idea, keren euy…dah lama ga maen kesini, terakhir pake MT sekarang udah bikin tips WP aja, keren mas Thomas, btw ta comot dulu ahh kebtulan lagi mbenerin template…