Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
A better Database Connection error page
  • Posted: 25.02.2005, 20:51
     
    denisrf
    rank:
    Helper Helper
    registered:
     February 2005
    Status:
    offline
    last visit:
    17.11.08
    Posts:
    411
    If you've ever had your site go down you've probably be confronted with that really ugly database connection error page. here is a way to make it at least look a bit better.

    I was inspired to write this after reading this thread:
    http://forums.postnuke.com/index.php?name=PNphpBB2&file=viewtopic&t=38078

    Around line 435 in includes/pnAPI.php you'll find:

    Code

    if (!$dbh) {
            //$dbpass = "";
            //die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg());
            die("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n<title>PostNuke powered Website</title>\n</head>\n<body>\n<center>\n<h1>Problem in Database Connection</h1>\n<br /><br />\n<h5>This Website is powered by PostNuke</h5>\n<a href=\"http://www.postnuke.com\" target=\"_blank\"><img src=\"images/powered/postnuke.butn.gif\" border=\"0\" alt=\"Web site powered by PostNuke\" hspace=\"10\" /></a> <a href=\"http://php.weblogs.com/ADODB\" target=\"_blank\"><img src=\"images/powered/adodb2.gif\" alt=\"ADODB database library\" border=\"0\" hspace=\"10\" /></a><a href=\"http://www.php.net\" target=\"_blank\"><img src=\"images/powered/php2.gif\" alt=\"PHP Scripting Language\" border=\"0\" hspace=\"10\" /></a><br />\n<h5>Although this site is running the PostNuke software<br />it has no other connection to the PostNuke Developers.<br />Please refrain from sending messages about this site or its content<br />to the PostNuke team, the end will result in an ignored e-mail.</h5>\n</center>\n</body>\n</html>");
        }


    Here is how I changed mine:

    Code

    if (!$dbh) {
            //$dbpass = "";
            //die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg());
            die("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n<title>FirstEdge - undergoing scheduled maintainance operations</title>\n</head>\n<body bgcolor=\"#bdcede\">\n<center>\n<h1>FirstEdge.Com.au</h1><h3>is undergoing scheduled maintainance operations<br />We appologise for any inconvenience</h3>\n <img src=\"images/db_error/maintenance.gif\" border=\"0\" hspace=\"10\" / alt=\"FirstEdge.Com.au is undergoing scheduled maintainance operations\">\n<h3>We will be back online as soon as possible<br />please call back again soon.</h3>\n</center>\n</body>\n</html>");
        }


    Maybe that will help a bit with making things look a bit better when things get stuffed up.
  • Posted: 25.02.2005, 21:36
     
    mhalbrook
    rank:
    Legend Legend
    registered:
     December 1969
    Status:
    offline
    last visit:
    20.11.08
    Posts:
    6516
    Or you can use the code from the 760 pnAPI function:

    Code

    if (!$dbh) {
            //$dbpass = "";
            //die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect" . $dbconn->ErrorMsg());
            include('includes/templates/dbconnectionerror.htm');
            die;
        }


    Then just create the dbconnectionerror.htm in the proper folder. :)
  • Posted: 25.02.2005, 21:42
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    The included template method has two advantages.

    1) easier to modify to your own requirements
    2) pnAPI.php is that bit smaller so PHP has less code to interpret on each page load.

    -Mark
  • Posted: 07.10.2005, 19:45
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    Where can I learn more about this? I've looked through the directories of .761 and don't find the place to template the database connection error page.

    What I mean to say is, can I just create the templates directory and drop a template in it and that's it?

    Thanks!

    EDIT: Nevermind... a server refresh revealed that those files were there all along.

    --
    Photography | PHP | Other
  • Posted: 07.10.2005, 19:54
     
    denisrf
    rank:
    Helper Helper
    registered:
     February 2005
    Status:
    offline
    last visit:
    17.11.08
    Posts:
    411
    alar,

    look in includes/templates
    the template is in there along with the "site off" template

    Best regards
    Denis
  • Posted: 07.10.2005, 21:08
     
    alarconcepts
    rank:
    Professional Professional
    registered:
     April 2004
    Status:
    offline
    last visit:
    21.01.08
    Posts:
    2723
    I just needed a refresh... thanks!

    --
    Photography | PHP | Other
  • Posted: 07.10.2005, 22:10
     
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.11.08
    Posts:
    13413
    As a side note, I'm looking at revising this error page to be a bit more friendly for future versions.

    --
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula