Salve qualcuno mi può spiegare questo errore ??
Ho questo codice:
Codice PHP:
$postdata = array('email' => $email,'mobilephone' => $phone);
$where = "username = '{$username}'";
$this->db->update('utenti', $postdata, $where);
che fa riferimento a questa funzione:
Codice PHP:
public function update($table, $data, $where) {
ksort($data);
try {
$set = '';
foreach ($data as $key => $value) {
$set.="$key = :$key";
}
$sql = "UPDATE $table"
. " SET $set"
. " WHERE $where";
session::set('campi', $sql);
$sth = $this->prepare($sql);
foreach ($data as $key => $value) {
$sth->bindValue(":$key", $value);
}
$sth->execute();
session::set('risultato', $sth->execute());
} catch (PDOException $e) {
echo $e->getMessage();
session::set('risultato', $e->getMessage());
}
}
Se faccio l'update di un campo alla volta funziona, se uso due o più campi va in errore come da titolo.
Qual è il possibile problema?
Grazie !