duandi4815 2015-11-05 00:53
浏览 201
已采纳

更改字段名称后,在“字段列表”中的未知列,在db中

I have a website that uses a database (www.eqtraders.com) It is run with PHP and MySQL

It seems that the host recently updated PHP and now 'yield' is a predefined keyword in PHP. So... I went everywhere and changed all field reference of yield to r_yield. I then change the database field names to 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

PHPMySQL reports the field names are r_yield (There are two tables other than recipes that also needed to be changed)

Screenshot of PHPMyAdmin with the name change. Field 3

Does anyone have any advice on what I might need to do?

  • 写回答

1条回答 默认 最新

  • duanbiaojin8860 2015-11-09 15:09
    关注

    In your sample code, the use of "item_id" and "r_yield" is not very clear, they might either be constants or strings.

    The problem lies on the PHP side. 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.

    • you use single quotes in your PHP code for strings :

      $rs = $data['item_id'];
      $rs_temp_data['item_id'] = $rsdata['item_id'][$i];
      $rs_temp_data['yield'] = $rsdata['yield'][$i];
      
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数