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 'AND (pages.page_class = 4 OR (page_class = 0 AND nav_sub_link IS NULL)) ' at line 2