Just a note that when you’re trying to insert data into a table and you get the error
Unknown column ‘the first bit of data what you want to put into the table‘ in ‘field list’
using something like
INSERT INTO table (this, that) VALUES ($this, $that)
it’s because you’ve not got any apostrophes around the values you’re trying to stick into the table. So you should change your code to:
INSERT INTO table (this, that) VALUES (’$this’, ‘$that’)
Nearly drove me mad, that one.
You won’t believe how mad that was driving me! Thanks!
Me too, many thanks
Thanks for the help!
Thank you very much for this piece of information…
You’re welcome, everyone - it’s silly there’s no good documentation for this problem on the interweb!
THANKS A LOT!!! sorry I shout, but it helped me very much!
thank you again!
lol
Thank you so much. I was really frustrated. Thank God there’s people like you who share the knowledge. See ya later and keep being successful and nice.
I’ve found that adding ticks to both the column fields and the values will cause the same error. For example:
INSERT INTO table (`this`, `that`) VALUES (`$this`, `$that`)
will cause the same error as
INSERT INTO table (this, that) VALUES ($this, $that)
THAAAAAAAAAAAAAANK YOOOOOOOOOOOOOOu
Hehe there’s a guy who posted a bug report about this on the mySQL site. Poor fellow, eh? Anyway, thanks for this concise reminder, which saved me loads of googling, and got me straight to the self-kicking.
I love you, will you have my babies? May I have your babies? Thank you for taking this offer into consideration.
That error can happen other times to, even when you have the quotes and such. I get it once and a while and my friend keeps getting it, just switch the field names around in the table and it usually works. Not sure why…
Just a note, make sure to use a normal apostrophe (single quote: ‘) instead of the “grave accent” (or whatever: `) if you’re still having problems.
cheers dude, been trying to work it out for days!
Oh man, that is so helpful, thank you! You are my current hero.
Thank you so much!!!
i had this error and was insaneee. tried a lot of procedures and incredibly this was my solution:
$add_all = ‘INSERT INTO ‘.$table.’ (IDTRANSACC, FECHATRANS, NOMPROD, IDPED, RECIB, SALIDA) VALUES (NULL, ‘.$fecha.’, “‘.$nomprod.’”, NULL, ‘.$recib.’, NULL)’;
mysql_query($add_all) or die(mysql_error());
REALLY CRAZY ISNT IT?
can someone explainme why i cant do like this:
$add_all = ‘INSERT INTO ‘.$table.’ (IDTRANSACC, FECHATRANS, NOMPROD, IDPED, RECIB, SALIDA) VALUES (NULL, ‘.$fecha.’, ‘.$nomprod.’, NULL, ‘.$recib.’, NULL)’;
mysql_query($add_all) or die(mysql_error());
Gracias amigo!
Really thanks dude!
Muchas Gracias.
Thanks,
It help me a lot ! !
In the immortal words of Charlton Heston, “A mad house!”
Many thanks!
Thank you - This helps me a lot!!
Thank you very VERY much for the information !! Saved me a lot of time
Woow, is there an explanation for this ? I was doing a select query and he did’nt find a numeric column untill I added the ticks.
Thank you!
Thank’s God you wasn’t born in the 18 century!
This helps me a lot !
Thank you
Thanks for this
I realise I am saying no more than the rest of the people above - but in all seriousness this was driving me nuts - variables shouldnt need ‘
Cheers
Chris
Thankyou VERY much!
You’re my hero.
Thanks a lot!
thanks a lot man!!! you saved one brain from a bullet!! go cowboys!!
Thanks, helped me today….wasted about 20 minutes before realizing someone else could have done the samething. =X
Thank you :D:D:D
I am teaching myself PHP/mySQL and wasted more than 48 hours trying to insert the values without success - until I got to your page. Thank you!
Thank you. Thank you. Thank you!! This small post was a Great help.
Thanks a lot … This helped. BTW if tom is not having your babies, Can he have mine instead ?
Not only was your post right to the point and incredibly helpful but you were also the first google hit, sometimes life is simple. Thanks
It also helps if you recheck the db and insure if the field you want to be filled is there.
thank’s ……1000x
yeh mate, good one my friend, iw as stuck and thought IT IS IMPOSSIBLE
but it was very possible
and now plausible
fucken ell thanx!
you have NO IDEA how many hours I’ve been trying to fix that one. Thanks!
thanks! how frustrating was that… can’t use quotes, has to be single quote. and just another note, if you are using MS word they’re single quotes don’t work either, use notepad.
Thank you so much. This was so obscure and irritating
THANK YOU! You wouldn’t believe how difficult it was to find a solution to this simple problem!
test
10x a lot man!
Found this through google - it’s saved me afters hours of frustration!
I’ve also run into this problem at the end of long Data Layer days. Where I mis-spell the table name in my stored procedure or query. The wording of the error tends to make you focus on the column in question, but it can be caused by quite a lot of things. Also, for those that have noticed that changing the order of the columns seems to work. I wouldn’t be surprised if after you change the order and run a successful test, you can change the order back, and it will still work. Most likely, when you move the text you are removing the offending whitespace character that is causing the Information Schema query to protest. Thanks for taking the time to post on this.
Matt
Again, Thanks so much……
Hey I have run into this problem also and I have actually written it the way your doing my customers website is a ASP application with MySQL 5.0.22 as DB
My actual code look like this:
Conn.execute(”INSERT INTO myTable (this,that,other) VALUES (’”& strThis &”‘,’”& strThat &”‘,’”& strOther &”‘)”)
Does anyone have any suggestions on how to fix this? considering the syntax seems to be correct according to this article.
Thanks,
Thank you ,I have solved this problem!
Hey guys,
I realize you all seem happy, but when I tried to do an update on a table, I get the same error, even though the field exists, and is printed in the Metadata that I got from the Resultset. unfortunately, I cannot swap my column positions….
Thank you very much.
Thanks a lot!
I had the same problem with UPDATE.
$query = “UPDATE dagplan SET f1 = $ny WHERE dagplan_id = $row[dagplan_id]“;
changing it (thanks to your advice!) to…
$query = “UPDATE dagplan SET f1 = ‘$ny’ WHERE dagplan_id = $row[dagplan_id]“;
Made it run without problem.
my savior
Thanx indeed
=), obrigado!!, legal
Thanks!
I’ve had problems with the keeping the ‘ around the variable when it comes to adding a NULL value to a table using amfphp.
Be nice not to have to try finding work arounds when the issue pops up.
Cheers,
Marty
this is awesome job bro………Had glitches while installing a site to clients server and I thought that it was server issue…..Thanks to Google and thanks to you……………
You are my hero!
Thanks!
Hello people, i have a big trouble, thats my code:
5- $sql->query(”INSERT INTO accounts (login, password, lastactive, access_level, lastIP, email)
6- VALUES(’$login’, ‘$pass’, ‘$lastactive’, ‘0′, ‘$last_ip’, ‘$email’)
7- “,”LS”);
thats the errorrrrrrrrrr.
MySQL ERROR: Unknown column ‘e_mail’ in ‘field list’
its drive me crazy, please, if you need the full code, told me.
sorry for my english, hasta pronto!
You are a ledgend!
GREAT THX MAN!!!
Yay, woot! It works, you are a genius. Was driving mad. Spent the last hour and half trying to find the error….cheers
thank you sooooooooooooooooooo much!!!!!luckly i found this site. or else, i’ll get crazy just like you guyyyyyyssssssssss!!!!!!!!!!
thankyou guy so much, now i can go to sleep , hope not dreaming with Unknown column ‘pepe’ in ‘field list’
Adding my name to the roll-call of thanks!
Little, helpful and googlable tidbits like this make the web.
Ok. I’ve been trying to get this to work for hours and so many of the websites on top of this one remark “Hey idiot you have a column listed that doesn’t exist” and I knew that that wasn’t the problem. Thank you SOOOO much.
thank you so much for this insight! *such* a weight off my shoulders.
You guys are the best. I have trying to do this for days but couldn’t figure it out. And now it worked like a charm.
Thanks
The thanks keep rolling in!
Thanks for the post!
You have helped me maintain the little sanity I have left!
…and another soul was helped. thanks!
ok, this is still not working for me….here is my error…
————————————————–
A Mysql error has occurred while running the script:
The query you are trying to run is invalid.
Mysql Error Output: Unknown column ‘activation_key’ in ‘field list’
SQL Query: UPDATE probid_gen_setts SET activation_key=’[--activation key--]‘
————————————————–
Yet another thank you!
Shouldn’t this point be better documented in the literature / tutorials out there? Spread the word, everyone!
Saved my reamining hair from being pullled from my head through sheer frustration - you are a saint sir
God bless you
That was of great help! Thanks much!!!
this help me a lot , thanks
Thanks a lot for this tip, you saved me a lot of time
Bless you kind sir. And bless google for pointing me to this.
INSERT INTO `FeedBack` (den_tu,tieu_de,noi_dung,trang_thai) VALUES (`Aptech`, `Feedback sach` , `Ko hay lam`, 1)
–> #1054 - Unknown column ‘Aptech’ in ‘field list’ ???
thanks heaps!
Thank you very much!!!
Thanks a lot!!
Now i have tried everything u said in the quotes and not in the quotes and all that but it was leaving me an error on line 1.
Here is what i did, there was an email field for which i changed the type from varchar(20) to varchar(25).
The error was the same but in line 1.
I simply restarted the MySQL server and it was all good and fine working..
Just thought i wud share for further references.
thanks! I was pulling hair on this one!
Thanks, was having this problem too, just tried it again and it worked like a charm.
Thank you =)
Thank you
Life savour!
thanks a lot
Thank you, thank you, thank you…was about to go bald…
I need help. Consider the database:
char | num
a | 1
b | 3
a | 4
b | 2
b | 4
d | 2
d | 1
c | 1
a | 2
I want to get a limited list for 2 ordered charaters:
a | 1
a | 4
a | 2
b | 3
b | 2
b | 4
I need to limit the counter characters, for example:
LIMIT 1, 3 may be result:
b | 3
b | 2
b | 4
c | 1
d | 2
d | 1
Who is the mysql command to do this?
Any help?
Thank you so much…I hate how anal mysql is about syntax
Thanks!!
Error: Unknown column ‘name’ in ‘field list’
come up with error i have done this and wot the other guy sugessted wth is up
Wow, two years and still helping people, people like me =P
THANKS MAN! It was driving me crazy!!!
({)
But what’s up with the same error while using prepared statements in java??
Hello people,
for example your making query that you want to insert it to database but also your want to make an archive of the query command to the other database…
so in first query use:
$query = “…VALUES (”\”.$sentance.”\”, “\”.$who.”\”, …)”;
this will solve your problems
I ran into this issue using prepared statements with PDO…
I thought I remembere3d what I was doing, I did this:
$sql=”insert into my_table values (’0′,$squid,$pickle,$duckling_id)’;
$statement=$pdo_db->prepare($sql);
$is_success=$pdo_db->execute();
this will give the same error, because I am not using prepared statements right.
the right way is of course:
$sql=”insert into my_table values (’0′,?,?,?)’;
$data=array($squid,$pickle,$duckling_id);
$statement=$pdo_db->prepare($sql);
$is_success=$pdo_db->execute($data);
Silly me.
thanks much!
Hi - thanks for the tip! I have a line of code that goes like this:
“UPDATE tablename SET myvar= ‘ ” . $myvar . ” ‘ WHERE Name = ‘ ” . $name . ” ‘ “;
I keep getting the same message that you had:
Unknown column ‘myvar’ in ‘field list’
any ideas?
Thanks you man, that helps me a lot
Fintan,
I’ve gone mad~! Decided to google “mysql Unkown column” and voila~!
Now, back to sanity.
… until the next event.
thanks~!
thanks for the tip. you saved me many hours of googling.
Thanks a lot. Its been driving me mad too
Awesome!!!!
O’ve been pullin me hair owt over that one for days!!!!
you saved me from hours of searching. very very good post
Thanks a bunch, another soul helped.
Nice blog by the way, an excellent layout, clear and beautiful.
How did I missed that!?
THANK YOU THABK YOU TRHANK YOU THANK YOU THANK YOU
Thank you!
I tried it in my script and it didnt work UNTIL I switch places of my column names…I dont know this happens…my nose nose is bleeding now got to go to hospital fast….
yay! thanx
thank you very much!!
You were the first one at Google and the solution for my problem.
Thank you alot!
Whooot, thank you so much. You saved my day , this thing have been driving me crazy
God bless you
You were my google solution. Thanks
Man, THANX
Hi, i have this query,
SELECT modx_site_content.id, modx_site_content.pagetitle, modx_site_content.content, modx_site_tmplvar_contentvalues.value FROM modx_site_content WHERE modx_site_content.parent = 16 OR modx_site_content.parent = 22 AND modx_site_tmplvar_contentvalues.contentid = modx_site_content.id ORDER BY RAND() LIMIT 1
which tells me unknown table ‘modx_site_tmplvar_contentvalues’ in field list but i’ve confirmed its there. what could be the problem?
seen the error, sorry
THANK U !!!!
1054 - Unknown column ‘clickandbuy_TransactionID’ in ‘field list’
update customers_basket set final_price=’0′, clickandbuy_TransactionID=’8ea284a’, clickandbuy_externalBDRID=’8e22a20a72′ where customers_id=”
Exception :Data truncation: Out of range value adjusted for column ’salary’ at row1
if u can solve it please reply me
i had a brain fart and totally forgot about it…thanks!!!
Thank you very much!
THANK YOU !!!!!!
Ooooooh! Thank you sooo much!
I became half mad because of this until I Googled and found this result. And this wasn’t even the first time….
Tupo
hi there,
i had the exact same problem. All good with the apostrophes but the problem kept coming up.
The explanation to my problem was that when i switch to see my database in PHPMyadmin, i found out that the offending columns had SPACES before them- YES WHITESPACES that do not show while you view your columns in the phpmyadmin.
You have to actually EDIT the column names in order to see the real value with the spaces.
So i guess this is probably because of Copy-Pasting the column-names…So from now on, ensure that you have manually constructed your database with your own hands, not just with copy-pasting
Thanks again - I hope that this will solve a lot more ppl from the same problem.
Wow, thank you very much.
Also, your SEO is good.
I entered this in the adressbar:
Unknown column ‘public’ in ‘field list’
and google/firefox redirected me instantly to this simple but very helpfull solution.
Thanks
Thank you for posting your frustrations - I was so close and this fixed it - thanks!!
Thanks! That did the trick
Dude, you are a life saver! I tried every possible permutation and combination before I got this tip from you!
Hi guys, happy new year!
I have the same problem but I can’t fix it!! I checked the ‘ and they are fine, I checked the db table in phpmyadmin and its fine, this is really driving me nuts, I haven’t slept in 2 days now!!
Here is the link for the page giving me trouble: http://www.pgiovannini.com/diagnostico/agregarUsuario.php
The error I get is this one: Unknown column ‘text’ in ‘field list’
I hope you guys can help me out! Thanks!
OK never mind, I got that one fixed…. But now is giving me another error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘±a, NombreUsuario, ApellidoUsuario, EmailUsuario, TipoUsuario FROM usuarios ORDE’ at line 1
Any ideas?
Never mind, bot both working, thanks!