If it's the same problem as the other thread, proper use of my will fix it. Don't you use use strict; use warnings;?
my $ID = ...; my $query = ...; my $sth = $dbh -> prepare($query); $sth -> execute; my @row = $sth -> fetchrow_array;
Another possibility is that there was an error performing the execute. Since you don't check for errors, did you specify RaiseError => 1?
Two other comments:
my $i = 0; for my $item (@{$clusters}) { ... $i++ }
can be written more simply as
for my $i (0..$#$clusters) { ... }
This one is a serious problem. Just adding quotes around the contents of $ID doesn't properly convert it from arbitrary text into an SQL string literal. You need one of the following, preferably the second:
for my $i (0..$#$clusters) { my $ID = $units[$i][0]; my $query = "select * from finalLevel3 where id=" . $dbh->quote($I +D); my $sth = $dbh -> prepare($query); $sth -> execute; my @row = $sth -> fetchrow_array; ... }
my $query = "select * from finalLevel3 where id=?"; my $sth = $dbh -> prepare($query); for my $i (0..$#$clusters) { $sth -> execute( $units[$i][0] ) my @row = $sth -> fetchrow_array; ... }
In reply to Re: perl, mysql: "fetchrow_array failed: fetch() without execute()"
by ikegami
in thread perl, mysql: "fetchrow_array failed: fetch() without execute()"
by gojira
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |