2016-31-12Query: select docs.*, CASE docs.tipofoto WHEN 'image/png' then 'image' WHEN 'image/jpg' then 'image' WHEN 'image/gif' then 'image' WHEN 'image/jpeg' then 'image' ELSE 'file' END as display from CLASIFICACIONES AS docs WHERE id_proyecto= AND ubicacion='inscritos' 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 ubicacion='inscritos'' at line 15