Forum Moderators: coopster

Message Too Old, No Replies

custom error message

         

MWpro

12:03 am on Jan 31, 2009 (gmt 0)

10+ Year Member



I run a database driven site, and every now and then there is a "Database Error" that brings up the default PHP error page (the page that says cannot connect to database).

My problem is that this error shows the root directory of my site, which I do not want.

Is there a way to make a custom PHP error page to hide this directory information?

Little_G

12:24 am on Jan 31, 2009 (gmt 0)

10+ Year Member



Hi,

This means you have display_errors [php.net] enabled which isn't a good idea for public facing servers. If you can turn it off in your php.ini then do, if you don't have access then you can do it at runtime [php.net].
The connect function of whatever database extension your using probably returns false on failure so you can check that and use it to return an error or continue.

Andrew

MWpro

12:47 am on Jan 31, 2009 (gmt 0)

10+ Year Member



Thank you for the quick response!

acemaster

2:19 am on Jan 31, 2009 (gmt 0)

10+ Year Member



You can also add an "or die('Database Connection Error')" too.