$query = "select * from finalLevel3 where id=\"$ID\";"; $sth = $dbh -> prepare($query); # I would suggest this: my $query = $dbh->prepare("SELECT * FROM finalLevel3 WHERE id='$ID'");
I personally like to captialize the SQL key words, but preferences vary. Also the single quote within the double quote will expand $ID just fine. There is no need for \" in this situation. I was amazed when I learned this.
I am also a bit confused about this:
foreach $item (@{$clusters}) { #..... }
I would think that since you are iterating over clusters, that something like this would be more clear:
So when do you need the extra {}? You need this when dereferencing an indexed expression, but not a non-indexed one. You also need the extra {} to make a list from a list ref returning function.foreach my $cluster (@$clusters) { #..... }
my @list = @{listRefReturningFunction()}; #also consider: my $r = {"a" => [1,2,3,4], "b" => [5,6,7,8], }; print @{$r->{"a"}}; #prints 1234 #here print @$r->{"a"} won't work #because this is a subscripted expression # now with list... my @x =(1,2,3,4); my $xref=\@x; print @$xref; #prints 1234 also #this works because there is no subscript
In reply to Re^2: perl, mysql: "fetchrow_array failed: fetch() without execute()"
by Marshall
in thread perl, mysql: "fetchrow_array failed: fetch() without execute()"
by gojira
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |