flush vs. sleep
| From: | DE) | Date: | Thu, 06 Apr 2000 18:51:18 +0000 |
| Subject: | flush vs. sleep | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-17688@lists.php.net to get a copy of this message | ||
Hello,
the problem is that flush sometimes does not work if it is followd by a
sleep e.g [example 1]:
print"Hello World";
flush();
sleep(5);
displays nothing until the 5 seconds are over!
The main target is to do a loop to get data out of a database to run a chat.
Here is the main function [example 2]:
$result_show=mysql_query("select author, message from chat where message_id
> '$last_msg'");
$row_show=mysql_num_rows($result_show);
function chat_loop($last_msg) {
while ($row_show = mysql_fetch_row($result_show))
{
print"$row_show[1]: $row_show[2]<br>";
flush();
$last_msg = $row_show[0];
};
sleep(2);
chat_loop($last_msg);
};
The strange thing is that it sometimes example 1 works. But only if NOT
running in a frame. Using IE5, Apache, PHP3
Any suggestions,
mikx
P.S. i can not drop the sleep --> stack overflow :-\