dead_db
Load custom DB error or display WordPress DB error.
Description
dead_db();
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.
This function was backported to WordPress 2.3.2, but originally was added in WordPress 2.5.0.
Usage
if ( !function_exists( 'dead_db' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } // NOTICE! Understand what this does before running. $result = dead_db();
Defined (1)
The function is defined in the following location(s).
- /wp-includes/functions.php
- function dead_db() {
- global $wpdb;
- // Load custom DBerrortemplate, if present.
- if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) {
- require_once( WP_CONTENT_DIR . '/db-error.php' );
- die();
- }
- // If installing or in the admin, provide the verbose message.
- if ( wp_installing() || defined( 'WP_ADMIN' ) )
- wp_die($wpdb->error);
- // Otherwise, be terse.
- status_header( 500 );
- header( 'Content-Type: text/html; charset=utf-8' );
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body>
- </body>
- </html>
- <?php
- die();
- }