Here is my code. Basically it generates a random string and I want to regenerate if the generated code exists in my db, but I always get recurring error.
What can I do to stop recurring error?
Here's my error
cannot redeclare exists_in_db (previously declared)
Code:
function exists_in_db($str)
{
$check_badge_in_paids = "sql query";
return mysqli_num_rows($check_badge_in_paids) > 0;
}
function rand_string()
{
$str = "";
do
{
$str = substr(md5(microtime()), 0, 5);
}
while(exists_in_db($str));
return $str;
}