Lee-Bartlett Posted September 19, 2008 Share Posted September 19, 2008 Ok i my form is on my local host atm and i feel it all in, goes in to the database and i was happy, untill i tried to enter more then 1 i get this message Error: Duplicate entry '0' for key 1, at the stage sat on google for about an hour reading arround and still couldnt find my answer. can anyone help me why i can only insert only 1 row. i manualy put 1 row in by phpmyadmin and then the form inserted one under that, my id number for first row i inserted is 1 and the one which i sent in via form = 0 if that helps. That is the code + the connection is in there to just didnt c+p it <html> <head> </heaD> <body> <form name="form1" method="post" action=""> <table width="418" align="left" cellpadding="0" cellspacing="0"> <tr> <td width="157"> Name:</td> <td width="259"><label for="name"></label> <input type="text" name="name" id="name"></td> </tr> <tr> <td>Email:</td> <td><label for="email"></label> <input type="text" name="email" id="email"></td> </tr> <tr> <td>WiFi Business Name:</td> <td><label for="buissnes_name"></label> <input type="text" name="buissnes_name" id="buissnes_name_name"></td> </tr> <tr> <td>WiFi Location;</td> <td><label for="textfield"></label> <input type="text" name="location" id="location"></td> </tr> <tr> <td>Free or Paid:</td> <td><input type="radio" name="radio" id="radio" value="radio"> <label for="radio"></label> <input type="radio" name="radio2" id="radio2" value="radio2"> <label for="radio2"></label></td> </tr> <tr> <td> </td> <td><label for="button"></label> <input type="submit" name="button" id="button" value="Submit"> <label for="button2"></label> <input type="reset" name="button2" id="button2" value="Reset"> <label for="sub"></label></td> </tr> </table> </form> <?php $sql="INSERT INTO tblbasicform (name, email, buissnes_name, location, free, paid) VALUES ('$_POST[name]','$_POST[email]','$_POST[buissnes_name]','$_POST[location]','$_POST[free]','$_POST[paid]')"; if (!mysql_query($sql,$connect)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($connect) ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/124997-solved-database-problem-only-1-row-allowed/ Share on other sites More sharing options...
Lee-Bartlett Posted September 19, 2008 Author Share Posted September 19, 2008 fixxed nvm forgot to turn on auto increment Quote Link to comment https://forums.phpfreaks.com/topic/124997-solved-database-problem-only-1-row-allowed/#findComment-645874 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.