WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to spruce up the "Error Establishing Database Connection" Page (3 posts)

  1. macharborguy
    Member
    Posted 5 years ago #

    Hi all,

    Very rarely does it happen, but sometimes I get the "Error Establishing Database Connection" error with WordPress. I am able to fix it with no problem, but between the time the error first happens to the time I fix it I would like to have some sort of page display that is more than just the error. Maybe a static page that looks like the rest of the website with information about the error.

    Does anyone know in which WordPress file I can find the error message in question?

  2. whooami
    Member
    Posted 5 years ago #

    you dont need to edit a file.

    /**
    * Load custom DB error or display WordPress DB error.
    *
    * If a file exists in the wp-content directory named db-error.php, then it will
    * be loaded instead of displaying the WordPress DB error. If it is not found,
    * then the WordPress DB error will be displayed instead.
    *
    * The WordPress DB error sets the HTTP status header to 500 to try to prevent
    * search engines from caching the message. Custom DB messages should do the
    * same.
    *
    * @since 2.5
    * @uses $wpdb
    */
    
    function dead_db() {
    global $wpdb;
    
    // Load custom DB error template, if present.
    if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
    require_once( WP_CONTENT_DIR . '/db-error.php' );
    die();
    }
  3. macharborguy
    Member
    Posted 5 years ago #

    AWESOME, even better. thanks

Topic Closed

This topic has been closed to new replies.

About this Topic