Monday 3 September 2018

The php: sql update query does not work as expected

I'm using the following query

$mysqli->query("UPDATE `edit_users` SET `password` = \"" . hash('sha512', $_POST['change_pw_password']) . "\", `single_login_pw` = NULL WHERE `id` = \"" . $userinfo['id'] . "\"");

As result this changes the password for the user with the specific id, but sets single_login_pw for all users to NULL.
Any idea why all single_login_pws are set to NULL and how to solve the problem?
Edit: I also tried to use mysql_query()...it's the same thing.

Try using LIMIT
"UPDATE `edit_users` SET `password` = '" . hash('sha512', $_POST['change_pw_password']) . "', `single_login_pw` = NULL WHERE `id` = '" . $userinfo['id'] . "' LIMIT 1"

I also changed your double quotes to single quotes around your strings.

0 comments:

Post a Comment