Friendlier styled "Error establishing a database connection" error message (1 post)

  1. Ollie Rattue
    Posted 6 years ago #


    I have always disliked the default unstyled "Error establishing a database connection" error message, which occurs if your db settings are incorrect or your db is offline/unreachable.

    A simple solution is to run it through the existing wordpress errror handling function wp_die() to give it some simple styling. The change would be as follows (bzr diff output):

    +++ wp-includes/functions.php	2009-11-12 12:21:30 +0000
    @@ -2570,23 +2570,7 @@
     	// Otherwise, be terse.
    -	status_header( 500 );
    -	nocache_headers();
    -	header( 'Content-Type: text/html; charset=utf-8' );
    -<!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" <?php if ( function_exists( 'language_attributes' ) ) language_attributes(); ?>>
    -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    -	<title>Database Error</title>
    -	<h1>Error establishing a database connection</h1>
    -	die();
    +	wp_die("<h1>Error establishing a database connection</h1><p></p>");

    Default error message screenshot:

    Styled error message screenshot:

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 6 years ago by Ollie Rattue
  • This topic is not a support question
  • WordPress version: 2.8.5


No tags yet.