Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

SQL syntax error in MySQL

mysql syntax syntax error

  • Please log in to reply
2 replies to this topic

#1 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 06 April 2010 - 01:35 PM

Hello,
I'm trying to insert a new record in the database tabel "movie_group" witht he following query:
$sql = "INSERT INTO movie_group (movie, group) VALUES ('$movie_id','22')";

but I get the following error message:
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 'group) VALUES ('8018','22')' at line 1

The fields "movie" and "group" exist in the tabel. The other fields of the tabel have default values.
Do you know whats wrong with the query?

Thank you.
  • 0

#2 DarkLordoftheMonkeys

DarkLordoftheMonkeys

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 232 posts

Posted 09 April 2010 - 03:45 PM

You don't have to address the columns by name. You can just set the values in the order that the fields appear, for instance:
INSERT INTO movie_group VALUES ('$movie_id','22');

MySQL never gives explicit error messages unless you make a common, easily detectable mistake like querying a column that doesn't exist.

I don't know what is with the quotes around the query. Are you using an API?
  • 0
Life's too short to be cool. Be a nerd.

#3 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 10 April 2010 - 02:10 AM

I fixed this, the problem was that "group" is a rezerved word, so I need to write it like this `group`.
  • 0





Also tagged with one or more of these keywords: mysql, syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download