RE: [PHP-DEV] flush vs. sleep From: Nick Newbold (nick <email protected>)
Date: 04/07/00

Splitting the sleep up from the first bit of code works fine.
Eg.

<HTML>
<h1> test </h1>
<BR><HR><BR>
<?

Function wait()
{
  echo "waiting.....";
  flush();
}

wait();

?>
<?

sleep (10);
echo "ok done";

?>
</HTML>

Hope this helps,

Nick

-----Original Message-----
From: Michael Krax (DE) [mailto:michael.krax <email protected>]
Sent: 06 April 2000 19:51
To: 'php-dev <email protected>'
Subject: [PHP-DEV] flush vs. sleep

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 :-\

--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>

This email has been virus scanned using Sophos Anti-Virus by intY (www.inty.net)

This email has been virus scanned using Sophos Anti-Virus by intY (www.inty.net)

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>