your query is failing because you don't have a valid join in your statement. the sql parser doesn't understand that it needs to join on threadid. this will probably work better
Code:
select
forum.title,
post.postid,
post.title,
post.username,
post.dateline
from
forum,
thread,
post
where
post.threadid='$each' and
thread.threadid=post.threadid and
thread.forumid=forum.forumid and
post.visible='1'
order by
post.postid asc
limit 1