Is there anything wrong with this code?

my $sth = $dbh->prepare($query);
$sth->execute;
my $ref = $sth->fetchrow_hashref;
while($ref) {
  $totalhrs += $ref->{quantity};
  my $tmpdate = $ref->{id};
  $tmpdate =~ s/(\d{4})(\d{2})(\d{2})\d+/$2-$3-$1/;
  print "<tr><td>$tmpdate</td><td>$ref->{item}</td><td>$ref->{quantity}</td>";
  $ref = $sth->fetchrow_hashref;
  if($ref->{id} eq $lastinvid) {
    print "<td>$ref->{fname} $ref->{lname}</td></tr>\n";
    $ref = $sth->fetchrow_hashref;
  } else {
    print "<td>N/A</td></tr>\n";
  }
  $lastinvid = $ref->{id};
}

I get this error over and over again in my Apache log:

DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /home/httpd/cgi-bin/report-myflights.pl line 38.
[Tue Oct 28 22:13:06 2003] [error] 17457: ModPerl::PerlRun: DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /home/httpd/cgi-bin/report-myflights.pl line 38.


It will cycle through the loop like 10 times and then die. I get output and an Apache error message all in one page. BTW, line 38 is the first '$ref = $sth->fetchrow_hashref' in the while loop.

--
Andrew Gaffney


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



Reply via email to