You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'png)) and (p.anyoDesde<=icon ) and (p.anyoHasta>=icon/apple ) and...' at line 9
SELECT p.*,tp.tpPubl,i.archivo,l.localidad, p.anyoDesde 'desde', case when p.anyoHasta= '3000' then 'presente' else p.anyoHasta end 'hasta' FROM `publicaciones` p left join tipospubl tp on tp.PKtpPubl=p.FKtpPubl left join imagenes i on i.FKrespCabeImpr=p.FKcabecera and i.FKgrupoimg = 2 left join localidades l on l.PKlocalidad=p.FKlocalidad where (p.FKtpPubl in (180.png)) and (p.anyoDesde<=icon ) and (p.anyoHasta>=icon/apple ) and p.anyoDesde>0 and p.anyoHasta>0 group by p.FKcabecera order by p.titulo ASC limit 0,16