in reply to Mysql select and store one field
When you retrieve only one row, there's no need for a loop. You can simply write
my ($post) = $sth->fetchrow_array; [download]