CWC index .

Customize the Error Message on phpBB


Once you have your phpBB up and successfully running, you might like to customize the error page that is seen on the occasional times that the host database cannot be contacted. This way, your visitors will see the same style of page as expected. It will look something like this for the phpBB default subSilver theme:

Powered by phpBB2 your phpBB name
your phpBB description


The database server for [your phpbb forum] on [your domain name] ($dbhost) cannot be contacted. It is currently under maintenance and should be available soon.

In the meantime, please look through other areas of

You may wish to look at phpbb support as well.


Powered by phpBB © 2001, 2005 phpBB Group

Before going any further, for security purposes, please check to ensure that you have the latest version of phpBB. If not, upgrade. Once you have done so and it is running correctly, here's how to customize your phpBB error page:

  1. First things first: backup and make a copy of includes/db.php.
  2. In a text editor, open includes/db.php.

    // Make the database connection.
    $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false);
    Type the following below the above coding with the words you would like your visitors to see when there is no connection to the phpBB database. Here is a suggestion:
    // create the error page header
    $header = <<<HEADER
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <title>[your phpbb forum name] - no connection to database</title>
    <link rel="stylesheet" href="templates/subSilver/subSilver.css" type="text/css" />
    <style type="text/css">
    opener {display:none;}
    <div id="opener">

    // create the error message
    $errormessage = <<<MESSAGE
    <title>no connection to database</title>

    <meta http-equiv="content-style-type" content="text/css" />
    <meta name="robots" content="noindex, nofollow" />


    <table width="100%" cellspacing="0" cellpadding="10" border="0" align="center">
    <td class="bodyline"><table width="100%" cellspacing="0" cellpadding="0" border="0">
    <td><a href="[]" target="_blank"><img src="templates/subSilver/images/logo_phpBB.gif" width="200" height="91" alt="Powered by phpBB2" title="Powered by phpBB2" border="0" vspace="1" /></a></td>
    <td align="center" width="100%" valign="middle">
    <span class="maintitle">[your phpBB name]</span><br />
    <span class="gen">[your phpBB description]</span>

    <br />

    <table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
    <td align="left" class="nav">error establishing a database connection </td></tr></table>

    <table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
    <th class="thHead" height="25"><strong>Information</strong></th>
    <td class="row1">
    <table width="100%" cellspacing="0" cellpadding="1" border="0"> <tr>
    <td> </td>
    <td span class="gen">

    <p>The database server for <strong>[your phpbb forum]</strong> on [your domain name] (<code>$dbhost</code>) cannot be contacted. In the meantime, please look through other areas of <a href="/">[]</a>.</p>

    <p>You may wish to look at <a href="">phpbb support</a> as well.</p>
    <td> </td>

    We request you retain the full copyright notice below including the link to
    This not only gives respect to the large amount of time given freely by the developers
    but also helps build interest, traffic and use of phpBB 2.0. If you cannot (for good
    reason) retain the full copyright we request you at least leave in place the
    Powered by phpBB line, with phpBB linked to If you refuse to include even this then support on our forums may be affected.

    The phpBB Group : 2002
    // -->
    Powered by <a href="" target="_phpbb" class="copyright">phpBB</a> &copy; 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>


    Please make sure that you have replaced [your domain name], [your phpbb forum name], [your phpBB name], [your phpBB description] and [] with your own names.

  3. Find
        message_die(CRITICAL_ERROR, "Could not connect to the database");
    Replace the above coding with the following:
    echo $header;
    message_die(CRITICAL_ERROR, $errormessage);

Save the file as db.php and upload it via ASCII to your phpBB includes folder.

© llizard 2007

CWC reference pages . ASCII-art . illustrations and gif animations . llinks to ridiculously useless sites . home page