Ho risolto sostituendo ad
ADDSLAHES
la funzione
HTMLENTITIES
così:
$nome=htmlentities($nome,ENT_QUOTES);

e così funziona