DBI
From: Andrew Gaffney (agaffney_at_technaut.darktalker.net)
Date: 10/29/03
- Next message: Andrew Gaffney: "Re: DBI"
- Previous message: Jeff 'Japhy' Pinyan: "Re: How to store arrays in hashes or objects?"
- Next in thread: Andrew Gaffney: "Re: DBI"
- Reply: Andrew Gaffney: "Re: DBI"
- Maybe reply: Tim Johnson: "RE: DBI"
- Maybe reply: Tim Johnson: "RE: DBI"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 28 Oct 2003 23:45:13 -0600 To: beginners@perl.org
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
- Next message: Andrew Gaffney: "Re: DBI"
- Previous message: Jeff 'Japhy' Pinyan: "Re: How to store arrays in hashes or objects?"
- Next in thread: Andrew Gaffney: "Re: DBI"
- Reply: Andrew Gaffney: "Re: DBI"
- Maybe reply: Tim Johnson: "RE: DBI"
- Maybe reply: Tim Johnson: "RE: DBI"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|