Woodburn2006 Posted January 30, 2008 Share Posted January 30, 2008 i get this error "Duplicate entry '0' for key 1" when i try entering data into my DB using a PHP form, i have tried to add data using HPMYADMIN but i get the same error any ideas to why this is happening? Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/ Share on other sites More sharing options...
revraz Posted January 30, 2008 Share Posted January 30, 2008 Sounds like you are either setting a auto_increment field with a number that's already used or a Unique field with a number that is used. Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453416 Share on other sites More sharing options...
Woodburn2006 Posted January 30, 2008 Author Share Posted January 30, 2008 i have a table set up with an auto_crement but i have it set up the same as i have it on other sites and it works fine thats why i dont understand why its doing it now, its not just one table its all of the tables in the database Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453426 Share on other sites More sharing options...
richiec Posted January 30, 2008 Share Posted January 30, 2008 change your primary key to a field which is something like 'ID' as INT and have that as auto increment, that should prevent you from getting a duplicate error. Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453437 Share on other sites More sharing options...
Woodburn2006 Posted January 30, 2008 Author Share Posted January 30, 2008 the field is set as id and INT but the problem still persists Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453443 Share on other sites More sharing options...
richiec Posted January 30, 2008 Share Posted January 30, 2008 paste your php form for the insert into blah blah Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453449 Share on other sites More sharing options...
Woodburn2006 Posted January 30, 2008 Author Share Posted January 30, 2008 $sql = " INSERT INTO products "; $sql .= " (name, info, img) VALUES "; $sql .= " ('$name', '$info', '$img') "; as i said it is set up exactly the same as other sites i have and there are no problems, it just seems to be something with this database Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453465 Share on other sites More sharing options...
revraz Posted January 30, 2008 Share Posted January 30, 2008 Post the DB structure. Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453466 Share on other sites More sharing options...
richiec Posted January 30, 2008 Share Posted January 30, 2008 what he said Quote Link to comment https://forums.phpfreaks.com/topic/88567-inserting-sql-error/#findComment-453514 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.