Reputation: 61
I have a problem I'm testing my table in mysql everything was working then I delete it the data now when I tried my php script running it gives me this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0'' at line 1 I checked my code everything seems right. Can anyone help me. Thank you
UPDATE NewsLetter
SET Active='1'
WHERE Email='".$email."' AND Hash='".$hash."' AND Active='0'
Upvotes: 1
Views: 3778
Reputation: 1529
I will actually save you the trouble of responding to the comments.
Simply put, don't do this! You don't appear to be sanitizing your input variables, and this method of string concatenation leads me to believe you're using the builtin mysql_* functions. Don't!
Try using PDO! Your query becomes:
$statement_handle = $database->prepare("UPDATE NewsLetter SET Active=1 WHERE Email = ? AND Hash = ?");
$statement_handle->execute(array($email, $hash));
Bind variables!
Upvotes: 1