| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Soon to be RICHdoggie! | 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 | 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 V5 Soon! |
| |
| | #3 (permalink) |
| New Member | 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
__________________ |
| |
| | #4 (permalink) | |
| Soon to be RICHdoggie! | Quote:
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) | |
| Senior Member | Quote:
http://dev.mysql.com/doc/refman/4.1/...ric-types.html | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |