Forum Moderators: coopster

Message Too Old, No Replies

Registration Form Problem

Registration Form Problem

         

appleg5ive

9:11 am on Jul 26, 2004 (gmt 0)

10+ Year Member



Okay, this is my very simple registration script, it works by re-entering the same page (register.php->register.php), but every time I run the script I get an error saying "Duplicate entry '0' for key 1", and I don't know what that means. I know that the error stems from this section "if (mysql_num_rows($result) == 0) {
$insert = "insert into users values ('','$user','$pass')";
$query = mysql_query($insert,$conn) or die(mysql_error());
$msg = "Thank you for joining Universal Domination!";
}", but I don't kow why. Any ideas?

<?

if ($user && $pass) {

$conn = mysql_connect("********.co.uk", "*******", "*********") or die(mysql_error());
mysql_select_db("*******",$conn) or die(mysql_error());

$sql = "select * from users where name = '$user'";
$result = mysql_query($sql,$conn) or die(mysql_error());

if (mysql_num_rows($result) == 0) {
$insert = "insert into users values ('','$user','$pass')";
$query = mysql_query($insert,$conn) or die(mysql_error());
$msg = "Thank you for joining Universal Domination!";
} else {
$msg = "Sorry, that username has already been taken, please choose a new one!";
}
}
?>

appleg5ive

9:20 am on Jul 26, 2004 (gmt 0)

10+ Year Member



Is the problem that I don't have the id se to auto_increment?

appleg5ive

9:26 am on Jul 26, 2004 (gmt 0)

10+ Year Member



No worries, that was the problem, all sorted now!