1

I am confused. I don't know what is the error. On execution I got a 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(creator,type,name,details,icon)values (6,'information sharing','test','j' at line 1"

my query is :

INSERT INTO group 
    (creator, type, name, details, icon) VALUES
    (6, 'information sharing', 'test', 'just for testing',
    'My friend/group_uploads/pic00_6_0d46839f6371fb84f6b6c682f5fc2c77.jpeg') 

this my table specification:

type      varchar(1000)
name      varchar(1000)
details   varchar(1000)
creator   bigint(20)
icon      varchar(1000)

please help me to correct the error .

1
  • 1
    just change table name "grou" to "grp" and try this query in PHP "INSERT INTO grp (type, name, details, creator, icon) VALUES ('6', 'information sharing', 'test', '0', 'My friend/group_uploads/pic00_6_0d46839f6371fb84f6b6c682f5fc2c77.jpeg');" @Shankar Damodaran is right group makes problem because of reserved word Commented Apr 7, 2014 at 9:33

3 Answers 3

3

group is a reserved word in MySQL. You need to surround it in backticks.

Like this..

insert into `group`(creator, type, name, details, icon) values ('6','information sharing','test','just for testing','My friend/group_uploads/pic00_6_0d46839f6371fb84f6b6c682f5fc2c77.jpeg')
            ^     ^

Try to avoid having such names for your columns and tables.

Sign up to request clarification or add additional context in comments.

Comments

0

Grou is Keywords in MySQL. So use backticks for those.

Try:

 INSERT INTO `group` 
        (`creator`, `type`, `name`, `details`, `icon`) VALUES
        (6, 'information sharing', 'test', 'just for testing',
        'My friend/group_uploads/pic00_6_0d46839f6371fb84f6b6c682f5fc2c77.jpeg') 

Comments

0

Even though by using backticks you can use keywords as table name , It is not recommended to use reserved word as table name

DO NOT DO IT.

Official list of reserved keywords: Reserved Keywords (Transact-SQL)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.