Page 1 of 1

Problem with Flush() and Ob_Flush()

Posted: Tue May 03, 2005 8:49 am
by Phrank
I have several images to preload for a web page. I wrote a nice routine to show a progress bar and update it after each image is preloaded. Works great on my PC. (XP with IIS). The one thing I have to do is flush the buffer each time I update the progress bar to see the change on the screen.

When I copy this program up to the hosting server, Unix based http://www.fatcow.com, I get an error each time it hits the following command:

<? flush();ob_flush(); ?>

The error is:

Notice: ob_flush(): failed to flush buffer. No buffer to flush. in c:\inetpub\wwwroot\portfolio.php on line 158

If I leave out the ob_flush() and just use flush() I get no error message but it does not refresh the screen and show the progress.

Any help here would be greatly appreaciated.

TIA Frank

Posted: Wed May 04, 2005 11:21 am
by anjanesh
For Apache Server flush() alone will do.
For IIS, I guess flush() is not working (dont know abt IIS 6 though) but ob_flush() does.
Really don't know how web servers handle these buffer flush methods but ob_flush() forces flushing of buffer and so the server may report an error when flush();ob_flush(); is used together.
If you are uploading to unix, just flush() will do the job.

Posted: Thu May 05, 2005 10:27 am
by pickle
The error makes sense. Flushing sends everything in the output buffer, to the client. If you flush() the buffer, that empties it. Calling ob_flush() afterwards also flushes the buffer, and turns on automatic calling of flush() after every output call. The error is just saying there's nothing in the output buffer (since you've just flush()ed it)

Posted: Thu May 05, 2005 10:30 am
by malcolmboston
ob_ functions are somewhat annoying to get working effectively in IE as ie will not show anything in the browser until a certain amount of information has been sent to it, kinda making the whole point of it somewhat useless.

off-topic i know, but you should be aware of this