| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | mysql error! gah - this keeps annoying me! :( This is the error I get when I try to input more records into a table. Code: Duplicate entry '127' for key 1 Why is this happening? How can I stop it? I have tried to change the auto_increment value, but it won't let me! ![]() Thanks Tom |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 392
![]() ![]() ![]() | Erm thats slightly confusing, when inputting into a table i always set the primary key to INT type. Set the value to 255 (thats the max you can go up to) and then set it to auto_increment. Try changing the structure of the table using the way i said above. Tell me how it goes.
__________________ -Beaver6813.com - Web Developer Extraordinaire! |
| |
| | #3 (permalink) |
| New Member Join Date: Jul 2006
Posts: 16
![]() | A primary key can't be duplicated it has to be unqiue that why people usually set it to auto_increment so sql automatically sets the key. beaver6813 will work and if you do want to set it like beaver6813 stated then you would have to check if the key exists in the table before inserting a new one
__________________ |
| |
| | THREAD STARTER #4 (permalink) | ||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I usually put the value "NULL" for the primary key field eg: Code: INSERT INTO table VALUES (NULL, 'PoorDoggie', 25); Thanks Tom UPDATE: Ah... i had the primary key field as a "tiny_int" not an "int". This is probably why? It appears to be working now I have changed it. | ||||
| |
| | #5 (permalink) | ||||
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=253267 http://dev.mysql.com/doc/refman/4.1/...ric-types.html | ||||
| |
| | #6 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 392
![]() ![]() ![]() | Rep gladly accepted
__________________ -Beaver6813.com - Web Developer Extraordinaire! |
| |
| | THREAD STARTER #7 (permalink) | ||||
| Soon to be RICHdoggie! Join Date: Jan 2005 Location: UK
Posts: 2,408
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ????: NamePros.com http://www.namepros.com/showthread.php?t=253267 I would be glad to give you some rep lol - I always forget. | ||||
| |