Support » Alpha/Beta/RC » Friendlier styled “Error establishing a database connection” error message

  • Hey,

    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" "">
    -<html xmlns="" <?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:

  • The topic ‘Friendlier styled “Error establishing a database connection” error message’ is closed to new replies.