Duplicate entry '0' for key 2
Can anyone tell me what Key 2 is?
What causes the above error?
What I did is I put an echo functionName in each function.
And it echoed it twice, which means that the above duplicate key 0 for key 2 means it tries to insert into the same values twice.
<?php
if ($winners < 25)
{
if (($contestantID -10) % 98 == 0)
{ functionName(); }
elseif (($contestantID -10) % 49 == 0)
{ functionName(); }
else { functionName(); }
}
else { functionName(); }
}
?>
I also did a echo on $contestantID, and it echoes the right value, however the number 0(zero) is what goes into the DB.
This how I get contestandID
$sql = "SELECT contestantID FROM tableName";
$result = mysql_query($sql) or die(mysql_error());
$userID = $contestantID++;
$sql = "UPDATE tableName SET contestantID = $userID";
?>
Why would my script cause the functioned to be called twice within the same script? If I define a value outside a function, I don't have to pass the variable to the function as a parameter, correct?
I would apreciate any help since I've been stuck at the same problem for some time now.
Thanks
Thx