in reply to [untitled node, ID 178308]
#!/usr/bin/perl -w use strict;
(Or, if you're using a reasonably recent version of Perl, use warnings; rather than the -w.)
In your case f.ex, the following code:while rather not recommendable as a casual reader might confuse the inner and outer $sth with one another, would at least have worked.my $sth = $dbh->prepare ("SELECT id, body FROM news"); $sth->execute (); while (my ($news_id, $news_body) = $sth->fetchrow_array()) { my $sth = $dbh->prepare ("SELECT COUNT(id) FROM comments WHERE id += $news_id"); $sth->execute (); # was this missing from your snippet accidentall +y? my ($comments) = $sth->fetchrow_array(); print "$news_id, $news_body, $comments"; }
Makeshifts last the longest.
|
|---|