简体   繁体   English

字段名称更改后,数据库中“字段列表”中的未知列

[英]Unknown column in 'field list', in db, after a change in field name

I have a website that uses a database (www.eqtraders.com) It is run with PHP and MySQL 我有一个使用数据库的网站(www.eqtraders.com),它使用PHP和MySQL运行

It seems that the host recently updated PHP and now ' yield ' is a predefined keyword in PHP. 主机似乎最近更新了PHP,现在' yield '是PHP中的predefined keyword So... I went everywhere and changed all field reference of yield to r_yield. 所以...我到处走,并将yield的所有字段参考都更改为r_yield。 I then change the database field names to r_yield . 然后,我将数据库字段名称更改为r_yield

I am confident that the code is sending the following query: 我相信代码会发送以下查询:

INSERT INTO recipes (item_id, r_yield, tradeskill, restriction, triv_low, triv_high, date_added, triv_display) VALUES ("51998", "1", "Spell Research", NULL, "432", "432", "2015:11:04", "432")

And for this, I get the error: 为此,我得到了错误:

Unknown column 'r_yield' in 'field list', in db: recipes db:“配方”中“字段列表”中未知的列“ r_yield”

PHPMySQL reports the field names are r_yield (There are two tables other than recipes that also needed to be changed) PHPMySQL报告字段名称为r_yield(除配方外,还有两个表也需要更改)

Screenshot of PHPMyAdmin with the name change. 名称更改的PHPMyAdmin的屏幕截图。 Field 3 领域3

Does anyone have any advice on what I might need to do? 有人对我可能需要做的事情有任何建议吗?

In your sample code, the use of "item_id" and "r_yield" is not very clear, they might either be constants or strings. 在您的示例代码中,“ item_id”和“ r_yield”的使用不是很清楚,它们可能是常量或字符串。

The problem lies on the PHP side. 问题出在PHP方面。 I suggest : 我建议 :

  • you rename the columns in the MySQL table back to "yield", since that didn't need to be modified in the first place, "yield" being a PHP keyword, not a MySQL keyword. 您可以将MySQL表中的列重命名为“ yield”,因为不需要首先对其进行修改,“ yield”是PHP关键字,而不是MySQL关键字。

  • you use single quotes in your PHP code for strings : 您可以在PHP代码中为字符串使用单引号:

     $rs = $data['item_id']; $rs_temp_data['item_id'] = $rsdata['item_id'][$i]; $rs_temp_data['yield'] = $rsdata['yield'][$i]; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM