MySQL not accepting text

mindstorm8191

New Member
Messages
24
Reaction score
1
Points
3
Hi. I am currently working on a web-browser game, and am having some difficulty with my admin section. I have a page which allows me to edit all available buildings in a large form, and once finished, updates everything in the database. The trouble is, when I try to save the description text for the buildings, I get an error. Here's an example of the full query, that I get an error on.

UPDATE build_facts SET desc='Provides food for all your people. This includes your army, so the larger army you have, the more food you will have to provide. Higher cropland levels will produce greater amounts of crop.' WHERE kind=1 AND level=1;

For the variable kinds, desc is a text field, and kind & level are integers. This is the error message I get:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc='Provides food for all your people. This includes your army, so the larger' at line 1

I'm honestly not sure how this becomes a syntax error, I'm certain there's no aposthope's in the text I'm storing. If anyone can explain why I'm getting this error, or knows of any way to try and work around it, I would appreciate the help.

Thanks
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
The table name DESC is a MySQL command, and cannot be used in that manor. You would have to encase the field name in MySQL style quotes (`) so it knows that you are not trying to use the command.

Code:
UPDATE build_facts SET `desc` = 'Provides food for all your people. This includes your army, so the larger army you have, the more food you will have to provide. Higher cropland levels will produce greater amounts of crop.' WHERE `kind` = 1 AND `level` = 1;
 
Last edited:
Top