Error Number: 1064
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near
‘Aventro”,”bc55825ec921b78c574576fbc6679cc346ee0494”,”8c0cf560bb77c28d6b7dd11’
at line 1INSERT INTO users(username, password, salt, email, user_created)
VALUES(”Aventro”,”bc55825ec921b78c574576fbc6679cc346ee0494”,”8c0cf560bb77c28d6b7dd1135a1a94f2”,”john.anon3@gmail.com”,
NOW())Filename: C:\wamp\www\hol\system\database\DB_driver.php
Line Number: 330
createuser model:
public function createuser($username, $password, $salt, $email)
{
$password = sha1($password . $salt);
$sql = "INSERT INTO users(username, password, salt, email, user_created) VALUES('".$this->db->escape($username)."','".$this->db->escape($password)."','".$this->db->escape($salt)."','".$this->db->escape($email)."', NOW())";
if ($this->db->query($sql)) {
return true;
} else {
return false;
}
}
Controller (model call)
$result = $this
->user_model
->createuser(
$this->input->post('username'),
$this->input->post('password'),
$salt,
$this->input->post('email'));
Your
$this->db->escape()returns string enclosed in single quotes. Use this query instead:Or remove enclosing from
$this->db->escape()– it would be better, I think.