当我将下面的函数添加到我的 PHP 页面时,尝试执行脚本超时。它出什么问题了?
include ('config.php');
function GenerateTransID() {
$unique_ref_length = 9;
$unique_ref_found = false;
$possible_chars = "23456789BCDFGHJKMNPQRSTVWXYZ";
while (!$unique_ref_found) {
$unique_ref = "";
$i = 0;
while ($i < $unique_ref_length) {
$char = substr($possible_chars, mt_rand(0, strlen($possible_chars)-1), 1);
$unique_ref .= $char;
$i++;
}
$tmp_id = "TR-" . $unique_ref;
$unique_ref = $tmp_id;
$query = "SELECT `transactionID` FROM `payment` WHERE `transactionID`='$unique_ref'";
$result = mysql_query($query) or die(mysql_error().' '.$query);
if (mysql_num_rows($result)==0) {
$unique_ref_found = true;
}
}
return $unique_ref;
}