WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Ollie Rattue
    Member
    Posted 4 years ago #

    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 @@
     		wp_die($wpdb->error);
    
     	// 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(); ?>>
    -<head>
    -<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    -	<title>Database Error</title>
    -
    -</head>
    -<body>
    -	<h1>Error establishing a database connection</h1>
    -</body>
    -</html>
    -<?php
    -	die();
    +	wp_die("<h1>Error establishing a database connection</h1><p></p>");
     }
    
     /**

    Default error message screenshot:
    http://img442.imageshack.us/img442/1049/wordpressdefaultdberror.png

    Styled error message screenshot:
    http://img30.imageshack.us/img30/6115/wordpressstyleddberror.png

Topic Closed

This topic has been closed to new replies.

About this Topic

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

Tags

No tags yet.