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:
![]() |
your phpBB name your phpBB description |
error establishing a database connection |
Information | |||
---|---|---|---|
|
Before going any further, for security purposes, please check http://www.phpbb.com/ 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:
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:// Make the database connection. $db = new sql_db($dbhost, $dbuser, $dbpasswd, $dbname, false); if(!$db->db_connect_id) {
// create the error page header
$header = <<<HEADER
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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;}
</style>
</head>
<body>
<div id="opener">
HEADER;
// create the error message
$errormessage = <<<MESSAGE
</div>
<title>no connection to database</title>
<meta http-equiv="content-style-type" content="text/css" />
<meta name="robots" content="noindex, nofollow" />
</head>
<table width="100%" cellspacing="0" cellpadding="10" border="0" align="center">
<tr>
<td class="bodyline"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="[yourdomain.com]" 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>
</td></tr></table>
<br />
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" class="nav">error establishing a database connection
</td></tr></table>
<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
<tr>
<th class="thHead" height="25"><strong>Information</strong></th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="1" border="0">
<tr>
<td> </td>
</tr>
<tr>
<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="/">[yourdomainname.com]</a>.</p>
<p>You may wish to look at
<a href="http://www.phpbb.com/support/">phpbb support</a> as well.</p>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</td></tr></table>
<!--
We request you retain the full copyright notice below including the link to www.phpbb.com.
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 www.phpbb.com. If you refuse
to include even this then support on our forums may be affected.
The phpBB Group : 2002
// -->
Powered by <a href="http://www.phpbb.com/" target="_phpbb" class="copyright">phpBB</a> © 2001, 2005 phpBB Group<br />{TRANSLATION_INFO}</span></div>
</td>
</tr>
</table>
</body>
</html>
MESSAGE;
Please make sure that you have replaced [your domain name], [your phpbb forum name], [your phpBB name], [your phpBB description] and [yourdomain.com] with your own names.
Replace the above coding with the following:message_die(CRITICAL_ERROR, "Could not connect to the database");
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