开发者

Field email not updating in MySQL table (using PDO)

I have a query running on a site that updates a user's profile. It updates every field but the email field as it should. Actually it's not doing anything at all with the email field.

I define my $email variable as such:

$email = str_replace(" ", "", trim($_POST['email']));

And then I use my database wrapper to update it:

MySQL::do_query(
    $db, 
    "UPDATE customer 
    SET 
        email=?,
        firstname=?, 
        surname=?, 
        phonenumber=?, 
        street_address=?, 
        postcode=?, 
        city=?, 
        extra_2=?,
        ssn=?,
        password=?
    WHERE customer_id=? 
    AND password=?", 
    array($email, $firstname, $surname, $phone, $address, $zip, $city, $extra_2, $ssn, StringConverter::generate_hash($email, $_POST['pw']), $customer, StringConverter::generate_hash($email, $_POST['pw']))
);
开发者_JS百科

But, then to the problem, it doesn't update the email field. Every other field it updates just fine. I've tried running a separate query updating just the email, that doesn't work either.

It works fine when inserting, just not updating. And by this point I have no idea what could be wrong. And the $email variable holds the correct email address, although the query seems to ignore it. Any ideas?


Have you tried updating multiple things along with the email? I'm guessing not, because I think if you change the email, then the entire update will not perform correctly... This is because you use $email in StringConverter::generate_hash($email, $_POST['pw']), but if the email is changed, then the row won't meet the password check in the where clause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜