lmayer
06-20-2006, 01:58 PM
Afternoon,
I am almost there but I cant seem to figure out why its skipping the first else. The first part checks for a record then checks for a restriction the first else says if a restriction stop everything and exit. It skips that and goes to the second else and I dont know why! Any thoughts would be great
Laura
## prepare the SQL statement
$sth = $dbh->prepare ("SELECT CONCAT(last_name,' , ',first_name)GuestName, Restriction FROM Location_Test.Resident_Access_tbl WHERE card_number = '$guest';");
## execute it on the database
$sth->execute ();
if ($GuestName) # There is a record
{
if ($Restriction eq 'None') #and no restrictions
{
# Insert the record
}
else { # $Restrictoin ne 'None' HERES WHERE IT SKIPS
print "Content-type: text/html\n\n";
print "The guest you tried to enter has the following restriction: <b>$Restriction</b>. Please contact a supervisor.";
exit;
}
}
else #AND GOES HERE
{
# There is no record - do the data entry
}
## close connection to database
$dbh->disconnect();
print end_html;
I am almost there but I cant seem to figure out why its skipping the first else. The first part checks for a record then checks for a restriction the first else says if a restriction stop everything and exit. It skips that and goes to the second else and I dont know why! Any thoughts would be great
Laura
## prepare the SQL statement
$sth = $dbh->prepare ("SELECT CONCAT(last_name,' , ',first_name)GuestName, Restriction FROM Location_Test.Resident_Access_tbl WHERE card_number = '$guest';");
## execute it on the database
$sth->execute ();
if ($GuestName) # There is a record
{
if ($Restriction eq 'None') #and no restrictions
{
# Insert the record
}
else { # $Restrictoin ne 'None' HERES WHERE IT SKIPS
print "Content-type: text/html\n\n";
print "The guest you tried to enter has the following restriction: <b>$Restriction</b>. Please contact a supervisor.";
exit;
}
}
else #AND GOES HERE
{
# There is no record - do the data entry
}
## close connection to database
$dbh->disconnect();
print end_html;