...

View Full Version : Realtime Echoing



amir103
05-02-2009, 08:37 PM
I've been running a php script on my shared hosting account, and this code typically runs for days as it indexes web pages. It constantly sends status info to the browser through 'echo'. Anyway, I got a dedicated server and after installing LAMP etc etc I ran the script and noticed that it doesn't show realtime information anymore - here's what i mean - take a look at this small script which echoes each second as it passes:

<?php
$counter = 1;
while ($counter < 200) {
sleep(1);
echo $counter."<br />";
$counter++;
}
?>

When I run this on my shared hosting account, it actually displays each second as it passes in realtime, while on the dedicated it keeps 'loading' for 200 seconds and then suddenly displays all the numbers. What must be configured differently for this to happen? (I obviously want it to run in realtime) They're both running php 5, and I don't think its so much the type of hosting but something with php.ini, any ideas why this is happening? I can post both php.ini files if it helps.

CFMaBiSmAd
05-02-2009, 09:14 PM
You need to disable all compression and buffering that php and your web server is doing. You can probably Google on how to do that for php and your specific web server.

The whole Internet is not designed to work the way are you attempting. I seriously suggest if you want to update information on a web page this way that you use AJAX. While you might get it to work on your current servers, sooner or later you will end up on a server that you won't have the ability to change the necessary settings. This is also dependent on browser accept type settings, which would be out of your control for a visitor to your site other than yourself.

amir103
05-02-2009, 09:43 PM
You need to disable all compression and buffering that php and your web server is doing.

Thanks I fixed it, I turned on implicit_flush to On in php.ini. I know what you mean though, I'm only using this script for server purposes it's not meant to be opened by visitors and it's practically impossible to convert it to use AJAX at this point. Thanks for your help I appreciate it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum