I am trying to edit a Mysql database. Can someone tell me why this is not working, it doesn't update anything
mysqli_query($con,"UPDATE Users SET day_started=1 WHERE email='$user_data['email']'");
$user_data['email'] works I checked it. I tried echoing it and it did echo the value I wanted. I also checked the database and the value I want it on of the fields in email.
Thank you for your help:)
Answer
Try this:
$user_email = mysqli_real_escape_string($con, $user_data['email']);
mysqli_query($con,"UPDATE `Users` SET `day_started`='1' WHERE `email`='".$user_email."'");
I suspect the answer lies with your not properly embedding a PHP variable in your query string. Check out those sexy full stops on each side of $user_email
. PHP loves it when you do that.
I also sanitized your input and stuff, and formatted your query with backticks because PHP also loves that.
No comments:
Post a Comment