0

Hey, I'm doing a simple INSERT command, can you tell me what's wrong with it? I won't bother you with the php right now, cause I'm simply trying to get it work in the MySQL command line. Here is the exact command:

INSERT INTO Birthdays(ID, firstname, lastname, birthday, group) VALUES('','Sam','Smith','June','Junior')

As far as I know, this is following syntax perfectly. But I get the following error:
[IMG]http://www.packerworld.com/nate_personal/sql_error.JPG[/IMG]
Notice how "group", which should be a field in my table, is formatted in the query as if it's a command, instead of a field? I just don't get it!

Maybe I've set the fields in my table up incorrectly? I'm kind of new at MySQL, so maybe my table isn't set up correctly. Here's a screenshot of my table:
[IMG]http://www.packerworld.com/nate_personal/table.JPG[/IMG]

4
Contributors
6
Replies
9
Views
10 Years
Discussion Span
Last Post by ad_rulz
0

I tell you, I do this every time. I work for about an hour or so trying to figure out a problem, trying to exhaust all my resources before trying here, but without fail, as soon as I post here, I will, immediately after hitting the "submit post" button, solve the problem on my own.

Apparently, I shouldn't name one of my fields, "group"? I guess "group" is a command in the MySQL syntax, so it was getting confused. I changed the field name to something else, and it works great. So is this a rule I missed? Or is there a way to name a field "group" without it messing up like this?

Thanks anyway. :lol:

0

Use backticks: `group`

Thanks. I guess one of these days I'm going to have to take a course on PHP and MySQL rather than just trying to do it all off the cuff. ;)

0

The first field, ID, is an integer and does not allow null values but you are passing a blank string ''. I think you will probably get runtime errors on that.

0

The first field, ID, is an integer and does not allow null values but you are passing a blank string ''. I think you will probably get runtime errors on that.

Well, I guess I could do with out it, but I run several scripts like that and never get a run time error because of that. But I guess it is uneeded.

0

Hey, I'm doing a simple INSERT command, can you tell me what's wrong with it? I won't bother you with the php right now, cause I'm simply trying to get it work in the MySQL command line. Here is the exact command:

INSERT INTO Birthdays(ID, firstname, lastname, birthday, group) VALUES('','Sam','Smith','June','Junior')

As far as I know, this is following syntax perfectly. But I get the following error:
[IMG]http://www.packerworld.com/nate_personal/sql_error.JPG[/IMG]
Notice how "group", which should be a field in my table, is formatted in the query as if it's a command, instead of a field? I just don't get it!

Maybe I've set the fields in my table up incorrectly? I'm kind of new at MySQL, so maybe my table isn't set up correctly. Here's a screenshot of my table:
[IMG]http://www.packerworld.com/nate_personal/table.JPG[/IMG]

Hi ,

I think if you do not mention the field that is auto_increment while inserting the data it should do. Because auto_increment will start generating value from 0 by default and hence it cannot be kept as NULL.

The following query might work for you.

[INSERT INTO Birthdays(firstname, lastname, birthday, group) VALUES('Sam','Smith','June','Junior');]

Cheers,
Adi.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.