TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   MySQL & Databases (http://www.talkphp.com/mysql-databases/)
-   -   Unknown column in 'field list' (http://www.talkphp.com/mysql-databases/4079-unknown-column-field-list.html)

stewart 03-26-2009 08:16 AM

Unknown column in 'field list'
 
Alright guys, I am totally 100% all and out stumped on this. It makes absolutely NO sense to me.

I have google'd quite a bit for a solution. I've come across many similar problems, the fixes range from adding different quotes, ticks, and as well as making sure the column doesn't have a space in its name.

If I run the following query directly in phpMyAdmin :
Code:

SELECT `salt` FROM `users` WHERE `username`='beezm';
It works fine. Returns my result.

When I try running it from a script of my own, it errors out and gives me
Code:

Unknown column 'salt' in 'field list'
Makes no sense. If my query was wrong, why does it run fine when I enter it manually ?!


Aggghhhh!!! I am done for tonight, making this post and heading off to bed. Any suggestions would be GREATLY appreciated.

Thanks guys. 8-)

Salathe 03-26-2009 10:47 AM

Show us the query that your PHP script is using.

allworknoplay 03-26-2009 02:05 PM

Quote:

Originally Posted by Salathe (Post 22542)
Show us the query that your PHP script is using.

Agreed, we're not mind readers!!! :-D

stewart 03-26-2009 03:48 PM

Sorry guys, but I'm a little confused as to what you need o_O.
Technically my script uses a more complex query , but I replace it with the same exact one I have listed above for testing purposes, and still manage to get the error.

allworknoplay 03-26-2009 04:43 PM

Quote:

Originally Posted by stewart (Post 22545)
Sorry guys, but I'm a little confused as to what you need o_O.
Technically my script uses a more complex query , but I replace it with the same exact one I have listed above for testing purposes, and still manage to get the error.

Well sometimes what you THINK you are writing in your script isn't what you are really coding...

Sometimes it takes another set of eyes to take a look....

stewart 03-26-2009 05:09 PM

Code:

mysql_query( "SELECT `salt` FROM `users` WHERE `username`='beezm';" , self::getLink() ) or die(mysql_error());
O_O

It's making me want to bash my head in >.< lol

I will go ahead and add.. This is technically part of a larger class that dynamically builds my query. But since I couldn't get it working, I've just gone all the way down to my actual mysql_query function to see what's going on. And that simple line above just won't work, it keeps spitting out the error I posted.
But like I said, when I put the same query directly into phpMyAdmin it works fine. Next step is to make a stand alone script to try to same thing I guess :S

But I just don't get it :(

allworknoplay 03-26-2009 05:11 PM

Quote:

Originally Posted by stewart (Post 22547)
Code:

mysql_query( "SELECT `salt` FROM `users` WHERE `username`='beezm';" , self::getLink() ) or die(mysql_error());
O_O

It's making me want to bash my head in >.< lol

I don't think you're suppose to have a semi colon there in the select statement??


mysql_query( "SELECT `salt` FROM `users` WHERE `username`='beezm'" , self::getLink() ) or die(mysql_error());

Salathe 03-26-2009 05:27 PM

The error just says that MySQL can't see a column named "salt" in the "users" table. Are you 100% sure that your code is talking to the right database?

stewart 03-26-2009 05:30 PM

You know, I half thought about not replying to this thread, and just disappearing forever. Because I now realize how retarded I am and why I shouldn't code at 3 in the morning...

I am talking to the wrong database indeed.

Thank you both very much.

Salathe, ... *sigh* lol.

Edit:
I truly feel like an utter idiot :-D .. An elated utter idiot though.

allworknoplay 03-26-2009 05:35 PM

Quote:

Originally Posted by stewart (Post 22550)
You know, I half thought about not replying to this thread, and just disappearing forever. Because I now realize how retarded I am and why I shouldn't code at 3 in the morning...

I am talking to the wrong database indeed.

Thank you both very much.

Salathe, ... *sigh* lol.

Edit:
I truly feel like an utter idiot :-D .. An elated utter idiot though.


Hey I've had that happen to me too before...it happens!

Salathe 03-26-2009 06:38 PM

Quote:

Originally Posted by stewart (Post 22550)
Salathe, ... *sigh* lol.

Happens to us all, once. ^^

Sakakuchi 03-27-2009 05:47 PM

or twice :D

WebSavvy 04-01-2009 12:51 PM

Try this:

Code:

SELECT `salt` FROM `users` WHERE `username` LIKE "beezm";
If your mysql select statement uses double quotes, be sure to escape any other double quotes used within the select statement.

Also, what version of mysql are you using?

If you want to wildcard the mysql search query and find usernames that start with "bee" you'd add the wildcard (%) AFTER the match to be performed:

Code:

SELECT `salt` FROM `users` WHERE `username` LIKE "bee%";
If you want to find usernames that end with "zm", you'd add the wildcard (%) BEFORE the match to be performed:

Code:

SELECT `salt` FROM `users` WHERE `username` LIKE "%zm";
hope this helps.

sophie 05-24-2012 05:18 AM

hello guys i have a same problem with him..i do not write code in mysql because im using mysql workbench.

Unknown column 'a_id' in 'field list'

i had tat a_id on my dtabse i dont know how i fix this error.help me!!


All times are GMT. The time now is 01:01 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0