TheBigB
Jun 13th, 2009, 03:16 PM
Hi there,
The last two hours I've been fiddling around trying to build a script for MySQL error trapping.
The problem particularly is mysql_select_db where I can't catch the error.
What I have at the moment:
function db_select($dbame){
$res = @mysql_select_db($dbname, $conn);
if (mysql_errno() > 0) {
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'error.php?code=6002&from='.$_SERVER['PHP_SELF'];
header("Location: http://$host$uri/$extra");
}
}
It doesn't give an error if a incorrect table name is used.
The question is:
Am I expecting php to give an error while it shouldn't or is there something wrong with the code?
By the way, if someone has a better redirection script, I would appreciate it.
The last two hours I've been fiddling around trying to build a script for MySQL error trapping.
The problem particularly is mysql_select_db where I can't catch the error.
What I have at the moment:
function db_select($dbame){
$res = @mysql_select_db($dbname, $conn);
if (mysql_errno() > 0) {
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'error.php?code=6002&from='.$_SERVER['PHP_SELF'];
header("Location: http://$host$uri/$extra");
}
}
It doesn't give an error if a incorrect table name is used.
The question is:
Am I expecting php to give an error while it shouldn't or is there something wrong with the code?
By the way, if someone has a better redirection script, I would appreciate it.