Ho un form in cui il cliente visualizza il suo profilo e può aggiornarlo.
Un a volta premuto su MODIFICA i dati sono mandati alla pagina profilo_mod.php

codice:
if(isset($_POST['action']) and $_POST['action'] == 'Submit'){

$ret = reg_check_profile($_POST);

	$status = ($ret === true) ? reg_profile($_POST) : REG_ERRORS;
reg_check_profile crea un array e controlla ogni campo bloccando la procedura se si verificano errori

Se non ci sono errori reg_profile dovrebbe aggiornare il database ma ecco l'errore:

codice:
function reg_profile($data){
	//modifico il profilo dell'utente
	global $_CONFIG;
	$id = reg_get_unique_id();
	$replace="UPDATE utenti SET mail='".$data['mail']."', icq='".$data['icq']."', aim='".$data['aim']."', msn='".$data['msn']."', yahoo='".$data['yahoo']."' WHERE id='$id'";
     $risultato=mysql_query ($replace) or die ("There is occurred an internal error");
Il database non viene aggiornato.

Premetto che la stessa procedura di controllo viene usata nella registrazione degli utenti e questa funziona (anche perchè l'ho presa su freephp.it.
Ecco come lavora la registrazione:

la pagina registrati.php manda i dati attraverso un form a register.php che li interpreta.

codice:
include_once("include/config.php");
include_once("include/reg.lib.php");

if(isset($_POST['action']) and $_POST['action'] == 'Submit'){

$ret = reg_check_data($_POST);
	$status = ($ret === true) ? reg_register($_POST) : REG_ERRORS;
	
	switch($status){
...
....

ecco reg_check_data:

codice:
function reg_check_data(&$data){
	global $_CONFIG;
	
	$errors = array();
	
	foreach($data as $field_name => $value){
		$func = isset($_CONFIG['check_table'][$field_name]) ? $_CONFIG['check_table'][$field_name] : null;

		if(!is_null($func)){
			$ret = $func($value);
			if($ret !== true)
				$errors[] = array($field_name, $ret);
		}
	}

Ed ecco reg_register:

codice:
function reg_register($data){
	//registro l'utente
	global $_CONFIG;
	
	$id = reg_get_unique_id();
	mysql_query("
	INSERT INTO ".$_CONFIG['table_utenti']."
	(username, password, mail, nickname, country, icq, aim, msn, yahoo, temp, regdate, uid)
	VALUES
	('".$data['username']."',MD5('".$data['password']."'),'".$data['mail']."','".$data['nickname']."','".$data['country']."','".$data['icq']."','".$data['aim']."','".$data['msn']."','".$data['yahoo']."','1', '".time()."','".$id."')");
}
La procedura è la stessa ma il risultato non è lo stesso.
Come mai il mio database non viene aggiornato con le modifiche fatte dal cliente?