473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Buffer flush doesn't work quite as expected

Hi,

I've got a PHP script (running on MacOS X, PHP 4.1.12) which uploads
bookings from one database to another, and I'd like to have the screen show
progress as it happens (each time I process a booking, I write a line
summarising it to the browser with 'print')

From RTFMing and Googling, it seems that I should be able to do this by
turning output buffering on and using ob_flush() et al. However, this only
sort-of works, in that instead of getting output line by line, I get a
multi-line chunk on the browser from time to time.

Am I stuck with having this chunk-by-chunk visualisation, or can anyone
please suggest a way that I can make it force each line to the browser as I
write it?

Thanks in anticipation,

David C
Aug 3 '05 #1
2 2299
Here is an example which works for me, but I personaly recommend not to
use buffering at all
<?
function sample($buffer) {
global $i;
if(!isset($i)) $i = 1;
$bufer = "$i<br />";
$i++;
return ($bufer);
}

// don't forget to start buffering
ob_start("sample");

ob_flush();
ob_flush();
ob_flush();
ob_flush();

// and don't forget to end it
ob_end_flush();
?>

Aug 3 '05 #2
In article <dc**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>, David Cartwright wrote:
From RTFMing and Googling, it seems that I should be able to do this by
turning output buffering on and using ob_flush() et al. However, this only
sort-of works, in that instead of getting output line by line, I get a
multi-line chunk on the browser from time to time.


the result you see may depend on your browser, web server etc...
I did something similar in perl and got character by character output in
mozilla but not in IE.

Bye.
Jasen
Aug 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Copa | last post by:
Hello, I am testing buffering an asp page and Flushing information out to the browser, hence i wrote the code in an asp page that follows this Message Post. The loops are suppose to simulate...
2
by: Bill Sun | last post by:
Hi, I have a quetion about to refresh the ostringstream buffer: like this. ostringstream buffer; buffer << 245; // then the buffer.str() = "245"; ......
0
by: Matthias Straka | last post by:
Hi! I'm working on a website with an IHttpHandler that listens to changes ina database and sends some text to the client. The client is always connected to the handler, this way I can use a...
2
by: Kiran | last post by:
Hello Everybody! I am writing a networking application in python for a small piece of hardware, in which there could sometimes be timeouts. I am using sockets to communicate to this device. Data...
12
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug...
22
by: semedao | last post by:
Hi , I am using asyc sockets p2p connection between 2 clients. when I debug step by step the both sides , i'ts work ok. when I run it , in somepoint (same location in the code) when I want to...
5
by: arnuld | last post by:
this is from mentioned section. i did not understand some things here: it means "flushing the buffer" and "writing to output device" are SAME thing, these are just 2 different names for the...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
4
by: DR | last post by:
When using System.IO.FileStream, I write 8 bytes, then seek to the start of the file, does the 8 bytes get flushed on seek and the buffer become a readbuffer at that point instead of being a write...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.