Home: Perl Programming Help: DBI:
What is no results found.


Feb 9, 2003, 7:37 AM

Views: 7139
What is no results found.

I've been looking through all the dbi documentation, loads of FAQ sites about dbi etc... But none seem to mention what to do when no results are found to your query.

$query = qq(SELECT field1, field2, etc FROM database WHERE email = "$email");

When I run my query, if the record being looked for is found, everything works correctly. However, if the record isn't found, it doesn't display anything.

How can I return a no record found message?

I'm probably being really stupid and missing something obvious but any help is very much appreciated!



Feb 10, 2003, 3:40 AM

Views: 7134
Re: [newbiecoder] What is no results found.

We need to see more code than just the query.

However you are fetching the rows then just do an if/else.

my @row = $sth->fetchrow; 

if (scalar @row) {

else {