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 page_active=1 and page_sub=0' at line 1--select count(*) as count from pages where page_type='general' and pub_id= and page_active=1 and page_sub=0