FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQL problem!!!





Talk2Tom11
I have had this same coding working for quit some time but now for some reason it has been giving me an error... if someone can please help me to understand what is wrong with my code I would really appreciate it.


Code:
INSERT INTO guest (id, make)
VALUES ('81211', 'Honda');
AftershockVibe
What is the error?

If the "id" field in the "guest" table is set to auto-increment you may not be able to insert a value manually.
Talk2Tom11
i found the problem... it is with the 'make'. 'make' is a key word in some versions of mysql. And it does not like it in the version that i am running.

However, 'id' is on auto-increment and there is no problem if you do assign it a value.
AftershockVibe
Talk2Tom11 wrote:
However, 'id' is on auto-increment and there is no problem if you do assign it a value.


Unless that value already exists. In which case it will fail or it will insert it anyway and mess up the whole system because your id's are no longer unique.

So, while it may work... It's not a good idea.
Talk2Tom11
AftershockVibe wrote:
Talk2Tom11 wrote:
However, 'id' is on auto-increment and there is no problem if you do assign it a value.


Unless that value already exists. In which case it will fail or it will insert it anyway and mess up the whole system because your id's are no longer unique.

So, while it may work... It's not a good idea.



True true... but within my code I check to make sure there is no doubles of a key.

Plus mysql will fail if there is a key that is the same.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.