poleman Posted February 8, 2007 Share Posted February 8, 2007 I hope you can help... I had this working a minute ago and now its gone and I'm getting and error code: Duplicate entry '0' for key 1 I really hope you can help me. Thank you. The php code is as follows: <?php $con = mysql_connect ("db778.oneandone.co.uk","dbo191523062","zfMcsqnB"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db191523062", $con);$sql="INSERT INTO phpbb_users(username, user_email) VALUES ('$_POST[name]','$_POST[useremail]')";if (!mysql_query ($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added";mysql_close($con) ?> with the form html code as follows: <form method="POST" action="newslettertest4.php"> Name: <input type="text" name="name" size="20"> Email: <input type="text" name="useremail" size="20"> <button name="B1">Subscribe</button></p> </form> Thanks Richard Quote Link to comment Share on other sites More sharing options...
only one Posted February 8, 2007 Share Posted February 8, 2007 lol u got a messy way of doing it ive made you the whole page <?php $host='db778.oneandone.co.uk'; $username='dbo191523062'; $pass='zfMcsqnB'; $database='db191523062'; mysql_connect ($host, $username, $pass); mysql_select_db($database) or die('Could not connect to the Database'); if (isset($_POST["name"])) { $useremail = $_POST["useremail"]; $name = $_POST["name"]; if($rsname==NULL) { echo "some form of error"; }else{ $query = "INSERT INTO phpbb_users(`username`, `user_email`) VALUES('$name','$useremail')"; mysql_query($query) or die(mysql_error()); echo "succesfull"; } } ?> <form method="POST" action="newslettertest4.php"> Name: <input type="text" name="name" size="20"> Email: <input type="text" name="useremail" size="20"> <button name="B1">Subscribe</button></p> </form> Quote Link to comment Share on other sites More sharing options...
only one Posted February 8, 2007 Share Posted February 8, 2007 btw error code: Duplicate entry '0' for key 1 usually means you got your feild on primary key but not on auto increasment, somewhere along the lines of that Quote Link to comment Share on other sites More sharing options...
poleman Posted February 8, 2007 Author Share Posted February 8, 2007 thank you so much!! however, when trying it, i got the error message... :-( anything else you can do to help or suggest where I'm going wrong? Thanks rich 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.