I am using the following code and would like someway to display errors and/or redirect
on event of crash
inside the IF block at about where the #ERROR COULD BE HERE point:
#!c:/perl/bin/perl.exe
require "../global.cgi";
use DBI;
BEGIN {
use CGI::Carp qw(carpout fatalsToBrowser);
#print "Content-type: text/html\n\n"; # get header out early
}
%GET = &global::get();
%POST = &global::post();
$username = $GET{'id'};
$password = $GET{'process'};
$test = &global::validate($username, $password);
$option = &global::get_option($username, 'd');
if ($test == 1 and $option == 1)
{
$MYSQL_DATABASE = "DFGDG";
$MYSQL_USERNAME = "DFGDHH";
$MYSQL_PASSWORD = "GJHFJFH";
$dbh = DBI->connect("dbi:mysql:$MYSQL_DATABASE", "$MYSQL_USERNAME",
"$MYSQL_PASSWORD");
$sth = $dbh->prepare("SELECT * FROM tblDisc'");
$rv = $sth->execute or return "2. $dbh->errstr";
###################################################################
#ERROR COULD BE HERE
#Alot of statistical evaluation work is being done with the recordset
#1. Error could be from the database interaction
#2. Error could be from the recordset manipulation
#
#In the event of a crash at this point in the application I would like to log
the error and/or redirect.
#Any ideas would help. Thanks in advance.
print "Location:manage_org.cgi?id=$username&process=$password\n\n";
}
else
{
# SIMPLE CATCH ALL IF USERNAME AND/OR PASSWORD IS WRONG
print "Location:invalid.cgi\n\n";
}
--------------------------------------------------------------------------------