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?

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.