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 'ORDER BY fecha DESC LIMIT 0,15' at line 1 SELECT SQL_CALC_FOUND_ROWS id,usuario,'ruta',titulo,left(trim(resumen),400),left(trim(texto),400),'',UNIX_TIMESTAMP(fecha) as fecha,tipo,'0' FROM madteam_net.usuarios_rutas WHERE usuario='Rodri' and tipo= ORDER BY fecha DESC LIMIT 0,15