You are here:  » Database Connection failure - I want a 404 error page


Database Connection failure - I want a 404 error page

Submitted by Paulzie on Wed, 2008-09-17 21:29 in

How can I get Price Tapestry to return a 404 error page when it failes to connect to the database?

Currently it displays a page with something along the lines of "database connection failed" - which is a "200" document sucessfully loaded page?

Long story, but one of my Price Tapestry sites is on unreliable hosting. I pay $4 a month to monitor it, and the monitoring is checking the website is up. As far as it's concenrend a database connection failed page is successfull.

Submitted by support on Thu, 2008-09-18 06:51

Hi Paul,

You could try this for starters - in includes/database.php, look for the following code on line 14:

    $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);

...and REPLACE this with:

    $link = @mysql_connect($config_databaseServer,$config_databaseUsername,$config_databasePassword);
    if (!$link)
    {
      header("HTTP/1.0 404 Not Found");
      exit();
    }

Cheers,
David.

Submitted by Paulzie on Thu, 2008-09-18 20:24

Cheers David, works a treat

serviceuptime.com :-)
eukhost.com :-(