This is why FatalError: as soon as I add the following code to the webpage, loading will be slow and the Error prompt will appear: Fatalerror: Maximumexecutiontimeof30secondsexceededinE: \ xampp \ htdocs \ business \ lib \ function.
As soon as I add the following code to the webpage, loading will be slow and the following error will occur: Fatal error: Maximum execution time of 30 seconds exceeded in E: \ xampp \ htdocs \ business \ lib \ functions. php on line 13
PHP code
$rand_invoice_id=rand(0000,9999);$current_time=date("Y-m-d H:i:s");$current_time_start=date("Y-m-d")." "."07:00:00";$tomorrow_time_start=date("Y-m-d", strtotime('+1 day'))." "."07:00:00";$yesterday_time_start=date("Y-m-d", strtotime('-1 day'))." "."07:00:00";$row=1;do{ $query="SELECT * FROM CART WHERE (invoice_id='$rand_invoice_id') AND (order_time BETWEEN '$current_time_start' AND '$tomorrow_time_start')"; $result=queryMysql($query); $rows=mysql_num_rows($result); if($rows != 0) { $rand_invoice_id=rand(0000,9999); }}while($row!=0);
I just want to get a shopping cart and generate an invoice ID at random, but the randomly generated IDs may be repeated. Therefore, first generate one randomly and then find it in the database for a certain period of time, if there is the same, it will be randomly regenerated into one, knowing that there are no duplicates.
I really don't know what the problem is. thank you! Take a look at it for me
------ Solution --------------------
$ Row = 1;
Do
{
......
$ Rows = mysql_num_rows ($ result );
.....
}
While ($ row! = 0 );
Endless loop! $ Row! = 0 conditions are always met