Click to See Complete Forum and Search --> : If else skips first else


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;

robertketter
06-21-2006, 09:32 PM
else { # $Restrictoin ne 'None' HERES WHERE IT SKIPS

First thing I notice is a mis-spelling "$Restrictoin" instead of $Restriction.

Maybe this is all that was wrong... If not let me know and I will look a bit harder.

Robert Ketter, www.robertketter.com

lmayer
06-22-2006, 08:26 AM
Yeah I caught that one too. I did figure it out eventually. Thanks for the feedback.

Laura