Page 1 of 1

Custom error page when connection to MySQL fails

Posted: Sat Sep 20, 2008 7:25 pm
by Augustas
It would be nice to be able to cutomize somehow the error message that appears when the MySQL server is temporally down.

By default AdoDB library shows message like this:
Database Connection Failed
Error: Access denied for user 'root'@'localhost' (using password: NO) (1045)
Function Performed: CONNECT
Host/DB: localhost/cmsms_website
Database Type: mysql
Currently I am using this kind of trick:
1. I created a static /page_error.html page under my website's root.
2. I edited /lib/adodb.functions.php file in the following way:

FIND

Code: Select all

function adodb_error($dbtype, $function_performed, $error_number, $error_message, $host, $database, &$connection_obj)
{
AFTER ADD

Code: Select all

	include_once(dirname(__FILE__).'/../page_error.html');
	exit;
So now, whenever by some reasons MySQL server is down, the visitor sees my custom "page_error.html" instead of revealing to him the MySQL username and database name.

Re: Custom error page when connection to MySQL fails

Posted: Sun Sep 21, 2008 1:59 pm
by blast2007
Augustas wrote: So now, whenever by some reasons MySQL server is down, the visitor sees my custom "page_error.html" instead of revealing to him the MySQL username and database name.
Thanks, nice trick, it should be added to CMSMS security wiki (and maybe to the core?)

Regards,
blast

Re: Custom error page when connection to MySQL fails

Posted: Thu Sep 25, 2008 4:17 pm
by Pierre M.
I have filed this as bug #2519 hoping your suggestion is followed.

Pierre

Re: Custom error page when connection to MySQL fails

Posted: Mon Oct 13, 2008 1:20 pm
by Pierre M.
Hello again,

there is response from Alby. Please see the followup http://dev.cmsmadesimple.org/tracker/?f ... group_id=6.

Pierre

Re: Custom error page when connection to MySQL fails

Posted: Sat Jun 20, 2009 12:24 am
by jmcgin51
Pierre - your link no longer works for some reason.

Here is the current link.
dev.cmsmadesimple.org/bug/view?id=2519

In a nutshell, place a file named "db_error.html" in the CMSMS root.  This file should contain whatever custom error you want the user to see in the event of an SQL error.  As long as this file exists, the "custom error" functionality is built-in to CMSMS out-of-the-box.  (No need for the edits noted in the posts above.)

Re: Custom error page when connection to MySQL fails

Posted: Thu Aug 27, 2009 9:51 pm
by Golf Gti
You do realize this is built into php?

all you have to do is create a db_error.html page with what ever you want it to say.