Codice PHP:
"SELECT * FROM articolo WHERE NomeImmagine = '$img' AND Attivo = 0" 
Immagino che NomeImmagine sia una stringa e quindi va delimitata