jwwceo Posted December 15, 2007 Share Posted December 15, 2007 I have a databse with an auto incrementing primary key , called reservation_id. the values in this field were auto incrementing fine. 1..2..3..and so on. I decided to make the reservation_id the same as my order number so I just edited the last entry to be somehing like 8427861, thinking the auto increment would juct increase from there...but now whenever I run an INSERT query, I get this error: Error: Duplicate entry '127' for key 1 with query INSERT INTO reservations (package_id, user_id, ccnum, exp_date, avs, total, num_people) VALUES('5', '6', '4111111111111111', '0108', '123', '180', '3') Any ideas??? James Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted December 15, 2007 Share Posted December 15, 2007 What datatype is the reservation_id column set to? I believe this error maybe to do with the datatype that column is set as, which by looking at the error its set to TINYINT. Change the datatype to INT for that column. Quote Link to comment Share on other sites More sharing options...
geusMD Posted December 18, 2007 Share Posted December 18, 2007 8427861 is just the highest number you can have. So if you want to store another row, it can't increment the id. just set your autoincrement value lower. in for example phpmyadmin give the following SQL command ALTER TABLE tbl_name AUTO_INCREMENT = *** *** is the lowest value from wehere you want the id to increment. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 18, 2007 Share Posted December 18, 2007 just set your autoincrement value lower. NO NO NO NO NO NO NO NO NO! Don't make your auto-increment column TINYINT -- make it UNSIGNED INT (or BIGINT), and you'll be fine forever. Don't set up a situation where your IDs can be resued -- that's EXACTLY why the DB won't let you do this! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.