Error in query. SELECT sec.id, sec.name, art.id art_id, art.article_num, art.title FROM articles_sections AS sec INNER JOIN articles AS art ON (sec.id=art.section_id) WHERE sec.id >0 AND edition = ORDER BY sec.order_id, art.article_num. 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 sec.order_id, art.article_num' at line 6