You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY p.id LIMIT 0, 19' at line 3 SELECT p.id,p.parent_id,p.forum_id,p.emote,p.userid,p.nickname,p.headimage,p.subject,p.content,FROM_UNIXTIME(p.dateline) AS post_datetime,p.edits,p.good_count,p.bad_count,p.attachs,p.device_id,p.mobile_id FROM bbs_posts AS p WHERE p.topic_id = ORDER BY p.id LIMIT 0, 19