tags:

views:

40

answers:

1

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?

+4  A: 

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.

Eric
getting this error "#1054 - Unknown column 'bob' in 'where clause'" When i replace $username with bob
Patrick
try replacing it with 'bob' (with the quotes)
Dave W. Smith
Works great now, thanks! Its generous people like yourself that help people learn and for that i am very appreciative.
Patrick
Glad to help, and glad you got it fixed!
Eric