•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 427,804 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,789 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 2475 | Replies: 6
![]() |
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:
As far as I know, this is following syntax perfectly. But I get the following error:
http://www.packerworld.com/nate_personal/sql_error.JPG
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:
http://www.packerworld.com/nate_personal/table.JPG
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:
http://www.packerworld.com/nate_personal/sql_error.JPG
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:
http://www.packerworld.com/nate_personal/table.JPG
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:
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:
Last edited by nathanpacker : Jan 6th, 2007 at 1:32 am. Reason: misspelling
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,222
Reputation:
Rep Power: 38
Solved Threads: 935
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.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
•
•
•
•
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.
•
•
Join Date: Aug 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 1
•
•
•
•
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:
http://www.packerworld.com/nate_personal/sql_error.JPG
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:
http://www.packerworld.com/nate_personal/table.JPG
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- mysql DELETE not working (PHP)
- php and mysql insert...where making me tear my hairs out!!! help!!! (PHP)
- mysql UPDATE not working! Why? (PHP)
- new to mySQL (MySQL)
- php wont submit data into the database (PHP)
Other Threads in the MySQL Forum
- Previous Thread: online tutorial
- Next Thread: order by....



Linear Mode