MySQL更新查询“字段列表”错误中的未知列

时间:2022-08-11 00:15:11

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.

解决了。解决方案如下回答。谢谢每一个人。

4 个解决方案

#1


1  

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.

我不知道为什么,但那对我有用。

#2


0  

'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添加column_name数据类型

#3


0  

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进行比较

#4


0  

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索引的表。

#1


1  

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.

我不知道为什么,但那对我有用。

#2


0  

'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添加column_name数据类型

#3


0  

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进行比较

#4


0  

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索引的表。