I have a telegram bot in php and a while that has to do about 3000 rounds. At some point the while freezes until I write to the bot any character
'''$query0 = "SELECT * FROM admintable
WHERE chatid
LIKE '161200987'";
if ($result = mysqli_query($link, $query0)){}
while($row=mysqli_fetch_array($result)){
$st=$row[stato];
}
while($st=="mandando"){
$query200 = "SELECT * FROM `RisparmioEasyGiftBot` where page = 'invia'";
$result=mysqli_query($link, $query200);
while($row=mysqli_fetch_array($result)){
$ch=$row[chat_id];
$page=$row[page];
$c=$c+1;
sendMessage($ch, "f");
$query2 = "UPDATE `RisparmioEasyGiftBot` SET `page`= '' WHERE chat_id = ".$ch."";
sendMessage(161200987, "mandato a $ch");
$result=mysqli_query($link, $query2);
$text=$text;
}
$query200 = "SELECT * FROM `RisparmioEasyGiftBot` where page = 'invia'";
$result=mysqli_query($link, $query200);
$query22 = "SELECT COUNT(*) FROM `RisparmioEasyGiftBot` WHERE `page` LIKE 'invia'";
if ($result = mysqli_query($link, $query22)){
$row=mysqli_fetch_array($result);
if($row[0]==0){
$query23 = "UPDATE `admintable` SET `stato`= '' WHERE chatid = ".$chatid."";
$result=mysqli_query($link, $query23);
}
}
}
if ($result = mysqli_query($link, $query0)){}
while($row=mysqli_fetch_array($result)){
$st=$row[stato];
}'''
question from:https://stackoverflow.com/questions/65649250/while-loop-problems-with-telegram-bot