I have been coding for a few hours on this thing, so I think I am missing something very simple here, but I can’t seem to find it.
I am getting these 2 errors
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 77
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 79
public function resetPassword($password, $email){
$rst = $this->db->prepare("insert into users (password) values (?) where email=? ");
$rst->bindParam('?', $password);
$rst->bindParam('?', $email);
$rst->execute();
if($rst->execute()){
return "Password changed!";
}
else echo "Could not change password.";
}
Am I forgetting something?
When using questions marks as placeholders, you send an array to the execute method, like so:
$rst->execute(array('placeholder1value', 'placeohlder2value'));However, if you want to use named placeholders, you would bindParam/bindValue them, like so:
Please read about the difference between
bindParamandbindValueAnd another note, your SQL query doesn’t make sense, do you mean to do an
UPDATE?