I am trying to have my page redirect to another script which will display all error messages if there should be any. Here is what I am trying to do:
//Prepare statement
$checkCode = $conn->prepare("SELECT COUNT(code) FROM subscribers WHERE code LIKE ?");
if(!$checkCode){
header('Location:'.$errorURL."?¬ification=prepareFailed");
die();
}else{
$checkCode->bind_param("s", $code);
if(!$checkcode){
header('Location:'.$errorURL."?¬ification=bindParamFailed");
die();
}else{
$checkCode->execute();
if(!$checkCode){
header('Location:'.$errorURL."?¬ification=executeFailed");
die();
else{
//store result in a variable etc.}
}
$conn
and $errorURL
are obviously declared. $code
is previously retrieved from the database.
This code redirects me to the page whose URL ends in bindParamFailed
, therefore the error comes from the bind_param
statement. If I comment out the if(!$checkCode){...}
part it work like a charm.
Why is it not working? Any ideas?
Are there any other (maybe more intelligent) ways of programming such a custom error page?