Invalid query A: 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 'AND media.ref_id = ORDER BY media.ordine, DESC' at line 1: SELECT, media.image_full, media.thumb_med, traduzioni.nome, traduzioni.descrizione FROM media JOIN traduzioni ON media.ref_class = traduzioni.classe_id AND media.ref_id = traduzioni.elemento_id AND 1 = traduzioni.lingua_id WHERE media.ref_class = AND media.ref_id = ORDER BY media.ordine, DESC