homepage Welcome to WebmasterWorld Guest from 54.211.100.183
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Help me on Mysql
jcmiras

5+ Year Member



 
Msg#: 8632 posted 6:31 pm on Jun 12, 2005 (gmt 0)

I have this code,

INSERT INTO `newbus` ( 'busid' )
VALUES (
'3'
)

And i got this 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 ''busid' ) VALUES (
'3'
)' at line 1

What seems to be the problem? Thanks

 

arran

5+ Year Member



 
Msg#: 8632 posted 6:37 pm on Jun 12, 2005 (gmt 0)

Try it without using quotes for table/column names:

INSERT INTO newbus (busid) VALUES ('3');

If busid is a numeric column, also remove the quotes from '3':

INSERT INTO newbus (busid) VALUES (3);

grnidone



 
Msg#: 8632 posted 6:40 pm on Jun 12, 2005 (gmt 0)

Have you tried to put a ; (semicolon) at thee end of the statement?

The way you do the statement (the pattern) is like this:

Insert into table_name
(columnName1, ColumnName2, ...)
Values (Value1, Value2, ...);

Birdman

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 8632 posted 6:41 pm on Jun 12, 2005 (gmt 0)

Your column names don't need to be quoted. If you want/need to quote the column names, use the back tick(`) instead.

INSERT INTO `newbus` ( busid )
VALUES (
'3'
)

or

INSERT INTO `newbus` ( `busid` )
VALUES (
'3'
)

Cheers

jcmiras

5+ Year Member



 
Msg#: 8632 posted 2:10 am on Jun 13, 2005 (gmt 0)

Thanks, now i know my mistake. My eyes are not realy good in differentiating ( ' ) and ( ` ).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved