unique random id
Posted
by Piyush
on Stack Overflow
See other posts from Stack Overflow
or by Piyush
Published on 2010-05-17T16:50:21Z
Indexed on
2010/05/17
17:01 UTC
Read the original article
Hit count: 187
I am generating unique id for my small application but I am facing some variable scope problem. my code-
function create_id()
{
global $myusername;
$part1 = substr($myusername, 0, -4);
$part2 = rand (99,99999);
$part3 = date("s");
return $part1.$part2.$part3;
}
$id;
$count=0;
while($count == 1)
{
$id;
$id=create_id();
$sqlcheck = "Select * FROM ruser WHERE userId='$id';";
$count =mysql_query($sqlcheck,$link)or die(mysql_error());
}
echo $id;
I dont know which variable I have to declare as global
© Stack Overflow or respective owner