Non bastava fare cut&paste di quello che ti ho dato, se scrivi così dopo aver chiamato mysql_query():
Codice PHP:
echo $query." ".mysql_error(); 
dovrebbe mostrarti la tua query che hai generato e gli errori che ti dà mysql e quindi puoi farti il debug !!
Che so, ad esempio magari scopri che $ident non ha il valore che ti aspetti...