I seem to be sending a do statement into an infinite loop, and I’m not quite sure why.
Here’s the loop…
do{//create a random number
$rnd = mt_rand();
//check it against existing numbers
$qrr = “SELECT PLrn FROM people WHERE PLrand = ‘$rnd'”;
$rsr = mysql_query($qrr, $link);
$nr = mysql_num_rows($rsr);
if($nr==0)
{
$rchk == “Y”;
}
}while($rchk != “Y”);
The idea is that we create a random number which is assigned to a user when he/she logs on. That random number rotates every 24 hours, but it must be unique.
The do statement is supposed to allocate a random number, and then check it against already stored random numbers to make sure it is unique. If it is, the loop changes the value of $rchk to “Y” and ends the loop. If not, it repeats the loop, generating and checking the random number until it finds one that is unique.
It doesn’t work, and times out after 30 seconds.
Any suggestions?
CTB