On Wednesday, June 11, 2003, at 02:10 am, Annie wrote:


no i want to ask what if someone enters a firstname and last name which doesnot exist in the database...in that case how i can verify and print an error msg that the data doesnot exist for this first name and last name.


Well a fairly simple way would be to check to see if there is a return from the query...



use strict; use DBI; . . . my $dbhandle=DBI->connect("DBI:mysql:data_base_name", "username", "password"); my $query = "SELECT * FROM table_name WHERE lastname = '$a2' AND firstname = '$a1'"; my $statementhandle = $dbhandle->prepare($query); $statementhandle->execute;

my @return

while (($lastname, $firstname, $age, $address) =
$statmenthandle->fetchrow()){

@return = ($lastname, $firstname, $age, $address)
}


if ([EMAIL PROTECTED]){

PRINT ERROR MESSAGE HERE
}
else {

PRINT DATABASE DATA HERE
}


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to