Search code examples
phpmysqlfieldlist

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

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?


Solution

  • 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];