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 <= '2017-03-27 08:35:35' ' 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 <= '2017-03-27 08:35:35' ) AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '2017-03-27 08:35:35' ) ORDER BY ordering ASC limit