Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: DBI forgets last recordby seattlejohn (Deacon) |
on Jan 09, 2003 at 07:06 UTC ( [id://225472]=note: print w/replies, xml ) | Need Help?? |
$sth->fetchrow_array() returns a row (assuming one exists), and has the side effect of moving "past" that row in the set of database results. With this line:
print "NO ITEMS IN CART" unless $sth->fetchrow_array();
you try to retrieve a row. There might not be one, in which case you print "no items". But if there is, you don't assign the return value to a variable, so it just gets thrown away -- yet the results pointer still moves forward. That row won't show up in the list you generate in your while loop. A possible fix could work something like this (untested):
$perlmonks{seattlejohn} = 'John Clyman';
In Section
Seekers of Perl Wisdom
|
|