something like this
Code: Select all
function generate_id($length2 = 11)
{
$range = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_';
$max = strlen($range) - 1;
// Generates random id of length $length.
$id = '';
for ($count = 0; $count < $length2; $count++)
{
$id .= $range[rand(0, $max)];
}
return $id;
}Code: Select all
$check = mysqli_query($mysqli, "SELECT ".$table.".token FROM ".$table." WHERE ".$table.".token = '".$random."'");
if(mysqli_num_rows($check) > 0){
//ERROR: DUPLICATE TOKEN, CREATE A NEW TOKEN NOW...
}Code: Select all
<?php
$length1=11;
function random_text($start,$length1)
{
return substr(md5(time().rand()),$start,$length1);
}
$code1=random_text(10,11);
echo $code1;
echo"<br />";
?>and actuality i need use it as pages id and i want it completely like youtube id without duplicate
ex:http://www.youtube.com/watch?v=AxlJV89mFHE
any help .