in reply to fetching rows problem
The first piece of code seems "valid" to me. Could you specify what exactly fails?
As for the second snippet, you have a typo in there (print $row->{'count(*)} you forget an apostrophe (') ). I would write it something like this (to make it more readable):
$st = $db->prepare("SELECT count(*) AS total FROM members"); $st->execute(); my $row = $st->fetchrow_hashref(); print $row->{total}."\n";
Update: You can use your approach, but don't forget the apostrophe (single quote):
print $row->{'count(*)'}."\n";
|
|---|