ERREUR: SELECT * FROM spectacles WHERE visible = 1 AND ((date_premiere = '' AND id < ) or date_premiere < '') ORDER BY date_premiere DESC, id DESC LIMIT 1 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 ') or date_premiere < '') ORDER BY date_premiere DESC, id DESC LIMIT 1' at line 1