0

Simple Question , in Java , there is Timer Class , or AlarmManager , or even a while(true) loop to Repeat somes Code , how can i achieve with Php Code , i want to repeat somes Php Code/Script , i have tried :

 while(true){
 ////Give me an Error , 'No Data Received from WebSite/Not Response
 }

 function Check(){
 ////Do Code
 Check()
 ////Syntax and Others Error , does Not Work
 }

 echo "<script>setTimeout('check()',10);"; ////does not Work too


 Additional Code :

 $q=mysql_query("SELECT message FROM $tbl_name WHERE pass='".$_SESSION['Logged']."'");
 while($row = mysql_fetch_array($q)){
 while(true)
 echo $row['message']; ///In French Language saying that the server closed the connection without sending any      Data, 
 Error : Erreur 324 (net::ERR_EMPTY_RESPONSE) : Le serveur a mis fin à la connexion sans envoyer de données.

 }
Nikita
  • 189
  • 1
  • 4
  • 16
  • Is this code surrounding in `` tags and does your website support PHP. Also you can't call the function infinitely inside itself. – Philip Whitehouse Feb 23 '13 at 12:14
  • if u want to repeat it a certien amount of repeats use `for` loop – Dan Barzilay Feb 23 '13 at 12:16
  • PHP is not really suited for an infinite loop. http://stackoverflow.com/questions/1765733/when-are-infinite-loops-are-useful-in-php – Chris Feb 23 '13 at 12:19
  • Nikita, please elaborate on your objectives. A PHP process is not intended to live across multiple requests (ie, a typical setup does not do this). It is expected for the script to terminate, at which time the server will send the generated output to the browser. By inserting an infinite loop, the script fails to terminate, the server never obtains the output, and the browser receives nothing (other than, eventually, a time out). – erisco Feb 23 '13 at 12:21
  • @Phillip , Yes and Yes , i have a DataBase , please Refer to my previous Post , Thanks . Dan ive already tried with no luck . erisco , please look at my previous post for more info about what i am trying to achieve , Thanks . – Nikita Feb 23 '13 at 12:37
  • look like you are right @erisco , but how can achieve this . look 'Monitor Change in DataBase PHP' in my previous Post** , Thanks – Nikita Feb 23 '13 at 12:42
  • The question assumes a category error. Do some reading on how a web server serves a page to a browser. Understand how PHP fits into that equation. – erisco Feb 23 '13 at 22:32

1 Answers1

0

Can't get what you want to do but as of what i understand your question you can use something like:

while ($something == true )
{
 //code to process here and keeps repeating until condition is met.
 myFunction();

}

function myFunction(){
//code of your function
}
Darryldecode
  • 543
  • 5
  • 10
  • $something must always be True , this is like while(true) wich i have tried with no luck , i edited my Post & added more Info – Nikita Feb 23 '13 at 12:38