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 live = 1 AND event_start IS NULL AND event_end IS NULL AND ((( s' at line 2 Query: SELECT * FROM articles WHERE category_id = AND live = 1 AND event_start IS NULL AND event_end IS NULL AND ((( start_date is NULL OR start_date <= NOW() ) AND ( end_date is NULL OR end_date >= NOW() ))) ORDER BY `start_date` DESC, `created` DESC