my $dbh = DBI->connect(
'DBI:driver:database:host', 'user', 'pass',
{RaiseError => 1, HandleError => \&bail_out},
);
####
my $dbh = DBI->connect(
'DBI:driver:database:host', 'user', 'pass',
{RaiseError => 1, HandleError => \&bail_out},
);
my $sql = qq{ SELECT COUNT(*) FROM profiles WHERE username=? };
# Original
#my $result = $sth->execute($username)
# or bail_out('Error executing SELECT');
# Modified
# Note that 'or' clause is removed
my $result = $sth->execute($username);
$dbh->disconnect;
####
sub bail_out {
my $dbh = shift;
$dbh->disconnect
or bail_out(msg => "Cannot disconnect from the database");
# prints html message
exit(0);
}