Whenever something goes wrong when Drupal tries to access a database (for example, Drupal can't select the database), a white screen with the Drupal icon and information pertaining to the database connection (username, server name, database name) are displayed. For obvious reasons this is a rather undesirable error screen to have on a live server.

I would like to know if it is possible to override this screen with one that is defined by an administrator (most likely from a custom module). I don't know where this screen gets set in Drupal 5, let alone whether or not it can be overriden by an administrator. Any help is greatly appreciated. Thanks.

Comments

matt_harrold’s picture

This CSS file decorates an otherwise very plain error screen, if you customize this stylesheet, you can make the database error screen look a little more like the rest of your site.

leonk’s picture

matt, I'm less interested at the moment about the style of the page as I am more interested about the content. While the stylesheet will certainly be useful, I am looking more to create a custom error message that lacks sensitive information regarding the database connection so that I'm not blaring that information out to anyone attempting to access the site.

I am intrigued nonetheless by the stylesheet, though. I will be sure to use that once I solve this issue.

matt_harrold’s picture

no worries,

have a look at the core file: includes/database.mysql.inc

this is where the actual page(s) are generated.

every time an error happens, there is code something like

    drupal_maintenance_theme();
    drupal_set_title('PHP MySQL support not enabled');
    print theme('maintenance_page', '<p>We were unable to use the MySQL database because the MySQL extension for PHP is not installed. Check your PHP.ini to see how you can enable it.</p>
<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
    exit;

You would have to edit this file and write your own error display code instead.

leonk’s picture

Thanks, I'll have a look at that as soon as I can.

leonk’s picture

Drupal 6 promises to have theming for maintenance pages such as the error screens mentioned above.

http://drupal.org/node/141727

I'm not sure if there is anything official on this yet as of this posting, but it seems like this will get added to Drupal 6 at some point (if it hasn't already).