MySQL Forums
Forum List  »  PHP

UPDATE value changed to 0 and other value not updated
Posted by: A Frog
Date: February 28, 2011 02:40PM

Hi everyone!

I'm trying to set up a "forgot password" script on my site. I've got a user's table with a couple of fields, including a "password" field (varchar(128)) and a "salt" field (varchar(50)). I'm trying to change the values with the following PHP Code:

$result = mysql_query("UPDATE `users` SET `password` = 'b8c25c088d0f249c4fb5fucdfd94b0e61fd939c01aa0be967078f3f5afb0170d4aae0b3131d0c87d6ca6ce7dea961661f78555c512d44ec91b5726b307181026' AND `salt` = 'T?*93q0xf6V:K]cd$IAO~*kZmikYE<.@:k@q*X1Ks_(uw+!pH@' WHERE `email` = 'test@test.com'");
if (mysql_affected_rows() == 0) {
$page->content .= 'Couldn\'t create a new password: the e-mail address doesn\'t exist in our database.';
}

In the code above I've filled in the PHP variables with example values, of course I use mysql_real_escape_string() in my real script. I always get the "couldn't create new password" error and the log shows a message about an invalid MySQL resource. When I look in my database the salt field isn't updated and still has the old value, while the password field has 1 character: "0", instead of the password.

What am I doing wrong? Why doesn't this work?

Thanks on forehand!

Options: ReplyQuote


Subject
Written By
Posted
UPDATE value changed to 0 and other value not updated
February 28, 2011 02:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.