finding file that creates "error establishing database.."

I'd like to customize the generic "error establishing a database connection" message when a system goes down. Tried to google to find out where this file exists within (presumably PHP?) but of course, all one finds are people trying to solve the actual problem.

So, does anyone know where this file lives? Is it part of PHP, MySQL, Nginx?

Thanks in advance… :-)

3 Replies

@cre8tives:

I'd like to customize the generic "error establishing a database connection" message when a system goes down. Tried to google to find out where this file exists within (presumably PHP?) but of course, all one finds are people trying to solve the actual problem.

So, does anyone know where this file lives? Is it part of PHP, MySQL, Nginx?

Thanks in advance… :-)

Find out what HTTP error return code PHP returns with that response and customise your HTML template for that return code. You should be able to do that within your PHP script depending on which PHP framework you use.

@cre8tives:

I'd like to customize the generic "error establishing a database connection" message when a system goes down.

[snip]

So, does anyone know where this file lives? Is it part of PHP, MySQL, Nginx?
That message is usually crated by the application having trouble connecting to the database. It is not a page, and is not created by any specific component of your stack (eg, PHP, MySQL or Nginx).

Depending on which application you are using (custom/rolled your own, Wordpress, Drupal, etc, etc) the error message will be different and will be created in a different file with different code.

Customizing this error message is trivial. Once you find the code file that handles the database connection you'll see either the generic message or the call to the function that handles all database errors. If you see the generic message you can customize it right there (after you make a backup of the file, of course). If you find a function that handles all database errors you will need to code find the file that contains that code and go from there.

Once you've found the code that does the error handling you can probably find some help by searching the internet for something like "mysql handling connection errors" (without the quotes)

Thanks James!

I wouldn't have immediately guessed that this message would be coming from WordPress, but indeed it is, in a specific functions file. That means I can customize it with our tech support number!

Now how to figure out why the site is going down in the first place, hahaha.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct