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 date desc, post_time desc' at line 1 FUNCTION:list_blog_posts - SQL:select * from blog_posts where published = 1 and (archived=0 or archived is null) and type= order by date desc, post_time desc