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 edicion > 0 and fecha_fin_envio <> '0000-00-00 00:00:00' ORDER BY edicion DE' at line 1