+ Reply to Thread
Results 1 to 3 of 3

Thread: MySQL not accepting text

  1. #1
    mindstorm8191 is offline x10Hosting Member mindstorm8191 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    19

    MySQL not accepting text

    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

  2. #2
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: MySQL not accepting text

    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 by Twinkie; 01-24-2010 at 06:44 PM.

  3. #3
    mindstorm8191 is offline x10Hosting Member mindstorm8191 is an unknown quantity at this point
    Join Date
    May 2009
    Posts
    19

    Re: MySQL not accepting text

    Ah - thanks, I was unaware that desc was a MySQL keyword. I'll keep that in mind in the future.

    Guess I should look at the keywords list from time to time:
    http://dev.mysql.com/doc/refman/5.0/...ved-words.html

+ Reply to Thread

Similar Threads

  1. Which is better postgresql or MySQL?
    By Kurai Kumo in forum Scripts & 3rd Party Apps
    Replies: 11
    Last Post: 12-10-2009, 08:17 AM
  2. MySQL vs PostgreSQL
    By vol7ron in forum Computers & Technology
    Replies: 9
    Last Post: 11-19-2009, 06:03 PM
  3. Replies: 14
    Last Post: 09-29-2008, 07:07 PM
  4. html/css help
    By swantonbomb88 in forum Programming Help
    Replies: 3
    Last Post: 05-01-2008, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers