WordPress: How delete and customize Error Establishing a database connection


Error-establishing-a-database-connection

Error Establishing a database connection?

Or in french: Error establishing the connection to the database

Well Yes, that is the message that appears on your Wordpress site where its database is temporarily overloaded or when there is an error in the file wp – config.php!

To avoid your visitors an error of this type page, here's how to proceed:

Create a page named db – error.php, that you will put in your wp-content folder of your WordPress, and insert one of the 2 codes:

Code1:

<?php // fichier db-error.php fichier=""?>
$host = $_SERVE['HTTP_HOST']R;
$uri = urlencode($_SERVE['REQUEST_URI']R);
the header("Location: http://google.com/search?q=cache:$host$uri");
exit();
?>

Now with code 1, your visitors will see more a page marked with Error establishing a database connection but will be sent directly to the Google cache so that they can, despite the error, still have the info they were looking! This is one I use here.

Code 2:

&lt;? php
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 1800'); 1800 sec
mail("Votre adresse mail", "Database Bug",)
("Technical problems (MySQL).", "From: the name of your site"); >
<!DOCTYPE HTML>
<html dir="ltr" lang="fr-FR"></html>
<head></head>
<title>503 service Temporarily Unavailable</title>
<style type="text/css"></style>
H1, p {}
font-family: Helvetica, sans-serif choice;
font-size: 24px;
color: #333;
}
p {}
font-size: 14px;
}
 
 
<body></body>
<h1>Oh F * ck! An error?</h1>
<p>No worries, the problem is only temporary! Or so it is my webhost that meets some bugs...</p>
 
 

This code 2 allows you to leave a custom message, you send a mail (Attention: If your database is KO, you risk being perceived as a spammer by your host!) In this case, delete the mail and technical concerns lines) and also to return to Google page 503 indicating a passenger problem!

What is fat (your email address, the name of your site, and the message instead of Oh F * ck ect…) ) in the code 2 is to customize by yourself!

Leave a comment

Your email address will not be published. Required fields are marked *