0
我試圖使用以下代碼來生成1500認證碼:如何在PHP中生成批量驗證碼?
<?php
include "../include/top.php";
$count=1500;
$end=0;
while ($end<$count)
{
//generate an authentication code
$string="ABCDEFGHJKLMNPQRSTUVWXYZ123456789";
$string= substr(str_shuffle($string),5,8) ;
//check whether generated code already exist
$query = "select count(*) from auth where code = '$string' ";
$stmt = prepare ($query);
execute($stmt);
$bind = mysqli_stmt_bind_result($stmt, $count);
check_bind_result($bind);
mysqli_stmt_fetch($stmt);
mysqli_stmt_free_result($stmt);
//If generated code does not already exist, insert it to Database table
if ($count == 0)
{
echo $string."<br>";
$query = "insert into auth (Code) values ('$string')";
$stmt = prepare ($query);
execute($stmt);
$end++;
}
}
?>
它僅產生1024碼,印在瀏覽器和在數據庫插入。然後生成一個錯誤:致命錯誤:最大執行時間超過60秒...... 然後我在php.ini中將max_execution_time的值更改爲350並重新啓動WAMP並再次運行相同的腳本,但它生成只有不到1000個代碼和瀏覽器顯示加載,直到完成350秒,併產生一個錯誤:致命錯誤:最大執行時間超過350秒...... ......
其實我想生成一個拉赫代碼在這個方法。如何成功運行此腳本的值爲
$count=100000
我已經用$ count = 1500嘗試過了,但它只生成667個代碼,並且腳本執行永遠不會結束。 – SCC