demonlazeros has asked for the wisdom of the Perl Monks concerning the following question:
(The variable $course is brought in from another db search.) The code above fails to execute the else statement if there is no data in the table, if there is data the code works. Ive tried everything I can think of. I need to be able to tell the student that he is registered this course but not for these.#======================= [ open_dbi ] ======================= my $sql = "SELECT * FROM $course"; my $query=$dbh->prepare("$sql") or die "Couldn't prepare statement: " . $dbh->errstr; if (defined($query)) { $query->execute(); ###################################################################### +######### while (@row=$query->fetchrow_array()) { foreach ($row[0]) { print "$course"; if ($row[0] eq $userid) { print "$userid you are registered for this course $course<BR>" +; }elsif ($row[0]) {print "$course";} } } ###################################################################### +######### $dbh->disconnect;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: testing for retuning value of DBI querry is empty
by pc88mxer (Vicar) on Apr 22, 2008 at 17:20 UTC | |
by demonlazeros (Acolyte) on Apr 22, 2008 at 17:54 UTC |