Jump to content

username field / column in table (is it reserved?)


Siggles

Recommended Posts

I am trying to run a simple select statement.

 

$result = mysql_query("SELECT *

FROM `users`

WHERE `username` = $usertoedit

");

 

The error I get is

 

Unknown column 'Roger' in 'where clause'

 

for example.

 

Why is this. I know one question asked will be does username column actually exist but I am certain it does.

 

Please help. Is there a way around this?

Link to comment
Share on other sites

To give you some clarity on what went wrong.

Say you set $usertoedit = "Roger";

Then if you echo'd out your query you should get the following:

SELECT * FROM `users` WHERE `username` = Roger

 

MySQL assumes (because you haven't used single quotes (') ) that you're asking if the column username equals the column Roger.

So in summation:

MAKE SURE YOU QUOTE YOUR STRINGS!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.