Hi, I have a file "global.php" - which contains my database connection.
If the database connection fails, I want it to redirect the user to a nice pretty page explaining all about the database error without any of the horrible mysql errors all over the place, which is easilly accomplishable.
<?
$connect=mysql_connect("localhost","user","xxx");
$select=mysql_select_db($database);
$ref=$_SERVER['HTTP_REFERER'];
if (!$connect) {
header("Location: http://www.site.com/databaseError.php?ref=$ref");
}
else {
header("Location: http://www.site.com/databaseError.php?ref=$ref");
}
?>
However, the above makes "ref" empty...
Basically, what I want to do is pass on the page into which global.php is being included, onto the databaseError.php page, so that it can then email me and tell me which page the database couldn't connect to.
For example:-
index.php has global.php included into it. The database won't connect. So I want it to then redirect the user to databaseError.php, and then that page to email me and tell me that the error occured whilst loading "index.php". Is there a way to do this? I know how to do the email etc. - i'm just not sure if you can find out which page the global.php was included into.
Thanks for your help if possible!
Carl