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 ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '2016-05-04 01:54:49' ' at line 1 SQL=SELECT id, type, name, description, clickurl, cid, params, publish_down, publish_up, state FROM news_banners WHERE state=1 AND catid = AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '2016-05-04 01:54:49' ) AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '2016-05-04 01:54:49' ) ORDER BY ordering ASC limit