I use this function to insert to database the user's errors. My public function is this:
public function set_error($var) {
$dsn = 'mysql:***;host=***';
$username = '***';
$passd = '***';
try {
$pdo = new PDO($dsn, $username, $passd);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
$stmt = $pdo->prepare("INSERT INTO errors (ip, code, browser, referer, script, email, date) VALUES (:ip, :code, :browser, :referer, :script, :email, :date)");
$params = array('ip' => $_SESSION['info_utente']['ip'], 'code' => $var, 'browser' => $_SESSION['info_utente']['browser'], 'referer' => $_SESSION['referer'], 'script' => $_SESSION['info_utente']['script'], 'email' => $_SESSION['sessione_attiva']['email'],'date' => $this->ftime());
$stmt->execute($params);
return TRUE;
} catch (PDOException $e) {
return FALSE;
}
}
I have a similar function (insert to account) and this works!
So i call the function set_error into another function (signup or login) if the user has an error, i call the function so: $this->set_error("error_1"); but doesn't work.
I checked the database and it is all ok! The name of columns are ok, and all are VARCHAR(255).
Precisely:
$this->set_error("error_1");
return "error_1";
Why this doesn't work?
Thanks in advance and sorry if my English is bad!