php MySQL更新查询中“字段列表”错误中的未知列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4641204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unknown column in 'field list' error on MySQL Update query
提问by Mustafa
i echoed the query below: (query is safe)
我回应了下面的查询:(查询是安全的)
UPDATE otelozellik
SET isim_tr='test',
aciklama_tr='<p>test1</p>',
uyari_tr='test',
tag_tr='test'
WHERE id='1'
Database Error: Unknown column 'aciklama_tr' in 'field list'
数据库错误:“字段列表”中的未知列“aciklama_tr”
I changed the order of columns, the one after isim_tr
keeps giving error. When I move isim_tr
to the last then the one after id
giving the same error. But moving them to the last position is not a solution for me because table will be dynamic to add new columns when necessary. need an absolute solution.
我改变了列的顺序,后面的那个isim_tr
不断给出错误。当我移动isim_tr
到最后一个时,在id
给出同样的错误之后。但是将它们移动到最后一个位置对我来说不是一个解决方案,因为表格将在必要时动态添加新列。需要一个绝对的解决方案。
UPDATE: LATEST SCREENSHOT: http://img5.imageshack.us/img5/7215/mysqlerror.jpg
更新:最新截图:http: //img5.imageshack.us/img5/7215/mysqlerror.jpg
Solved. Solution is answered below. Thanks everyone.
解决了。下面回答解决方案。谢谢大家。
采纳答案by Mustafa
Problem is solved. Thank you a lot everyone for their help.
问题解决了。非常感谢大家的帮助。
Right Query for solution is:
解决方案的正确查询是:
UPDATE `holidaycholic`.`otelbilgi` SET `otelbilgi`.`isim_tr`='test2', `otelbilgi`.`aciklama_tr`='<p>test2</p>', `otelbilgi`.`uyari_tr`='test2', `otelbilgi`.`tag_tr`='test2' WHERE `otelbilgi`.`id`=1
No idea why but that worked for me.
不知道为什么,但这对我有用。
回答by Youssef
Here is the syntax which works for me all time:
这是一直对我有用的语法:
"INSERT INTO table(`code`, `description`) VALUES ('".mysql_real_escape_string($code)."', '".mysql_real_escape_string($description)."')";
"table" is a table with an AUTO_INCREMENT index.
“table”是一个带有 AUTO_INCREMENT 索引的表。
回答by MrGlass
'field list' errors are caused when you try to load data into a field that doesn't exist. Double check that you spelled your field names correctly.
当您尝试将数据加载到不存在的字段时会导致“字段列表”错误。仔细检查您的字段名称拼写是否正确。
Your post says that you need to add "dynamic columns". A properly structured database shouldn't have a need for that sort of thing. However, if you do want to add columns from php, you need to add them to the table before you try to insert data in those fields. You can use the ALTER TABLE statement to do this:ALTER TABLE table_name
ADD column_name datatype
您的帖子说您需要添加“动态列”。一个结构正确的数据库不应该需要那种东西。但是,如果您确实想从 php 添加列,则需要在尝试在这些字段中插入数据之前将它们添加到表中。您可以使用 ALTER TABLE 语句来执行此操作:ALTER TABLE table_name
ADD column_name datatype
回答by Basic
Just to double-check are all the characters you're using the standard ASCII characters or are you using an unusual character set?
只是为了仔细检查您使用的是标准 ASCII 字符的所有字符还是您使用的是不寻常的字符集?
Try inserting data into the table using phpMyAdmin or similar - If it works, copy the code it generates and run it yourself using the mysql client.
尝试使用 phpMyAdmin 或类似工具将数据插入表中 - 如果有效,请复制它生成的代码并使用 mysql 客户端自己运行它。
Assuming that still works, compare the generated code with the SQL generated by your PHP
假设仍然有效,将生成的代码与您的 PHP 生成的 SQL 进行比较