Reputation: 10117
I'm trying to update a field where username = $username
UPDATE userinfo SET password = $newpass WHERE username = $username
However, I'm getting the error "#1054 - Unknown column 'bob' in 'where clause'" when I replace $username
with bob
.
Any idea how to correctly write this?
Upvotes: 1
Views: 139
Reputation: 95153
Aha! After your comment, it's clear that you're not wrapping text in quotes:
UPDATE userinfo SET password = $newpass WHERE username = '$username'
Since $username
is a text value, you need to put single quotes around it so that SQL parses it as text, not as a column.
Upvotes: 4