Support » Fixing WordPress » How to change message “Error establishing a database connection”

  • Is there a way to change this message to say something else.

    Would be nice to add that the site will be back in a few mins or something.

    ” Error establishing a database connection. This website will be back in a few minutes.”

Viewing 7 replies - 1 through 7 (of 7 total)
  • Somewhere there is a plugin for maintenance mode, if i can remember.

    May be it isn’t what you want exactly, but… i guess you can not change php error messages so easy.

    whooami

    (@whooami)

    Member

    Would be nice to add that the site will be back in a few mins or something.

    create the file, this functionality is already available.

    // 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();
    	}

    wp-content/db-error.php <—- assuming you havent changed your content dir.

    Thank you whooami.

    where is this functionality code placed? I mean in which php file?
    I’m asking because it doesn’t work for me even though I placed a file db-error.php in the wp-content directory

    thetooon

    (@thetooon)

    @vici: wp-includes/functions.php – dead_db()

    thetooon

    (@thetooon)

    It seems that it doesn’t work for me neither.

    thetooon

    (@thetooon)

    It will never work.

    Because in wp-includes/wp-db.php on line 372, if connection to db failed – it failed. Without even attempt to call dead_db():

    `
    $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true);
    if (!$this->dbh) {
    $this->bail(sprintf(/*WP_I18N_DB_CONN_ERROR*/”
    <h1>Error establishing a database connection</h1>
    <p>This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at %s. This could mean your host’s database server is down.</p>

    • Are you sure you have the correct username and password?
    • Are you sure that you have typed the correct hostname?
    • Are you sure that the database server is running?

    <p>If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.</p>
    “/*/WP_I18N_DB_CONN_ERROR*/, $dbhost), ‘db_connect_fail’);
    return;
    }`

    Looks like dead_db() is a orphan function.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to change message “Error establishing a database connection”’ is closed to new replies.