Help - Search - Member List - Calendar
Full Version: Echoing statements during loop
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Nick Weisser
Hi there,

I've written a script that reads data from different csv files and then
inserts it into a MySQL db in several steps.

I'd like to print out a statement after every successful import step,
but the problem is that the statements are only echoed after the whole
script has been executed.

Could anyone please give me a pointer as to what I'm doing wrong? Or do
I have to give more detailed information on the script I've written?

Thanks,
Nick

Exyle
If you can post your script I can probably help, without seeing it I
can't really say anything though.

Nick Weisser wrote:
QUOTE
Hi there,

I've written a script that reads data from different csv files and then
inserts it into a MySQL db in several steps.

I'd like to print out a statement after every successful import step,
but the problem is that the statements are only echoed after the whole
script has been executed.

Could anyone please give me a pointer as to what I'm doing wrong? Or do
I have to give more detailed information on the script I've written?

Thanks,
Nick


Kimmo Laine
"Nick Weisser" <[Email Removed]> kirjoitti
viestiss:42b04e49$[Email Removed]...
QUOTE
Hi there,

I've written a script that reads data from different csv files and then
inserts it into a MySQL db in several steps.

I'd like to print out a statement after every successful import step, but
the problem is that the statements are only echoed after the whole script
has been executed.

Could anyone please give me a pointer as to what I'm doing wrong? Or do I
have to give more detailed information on the script I've written?



I'd say the server uses output buffering. That speeds up the script
execution, but prevents partial output, like you described. The server sends
the page only when the script has completely executed. There is a function
called flush() that you can use to force server to output the buffer, but
from what I know, it doesn't work with IIS6 for example. Don't know about
apache...

here's what the manual says about it:

void flush ( void )

Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a
web server, etc). This effectively tries to push all the output so far to
the user's browser.

flush() has no effect on the buffering scheme of your webserver or the
browser on the client side.

Several servers, especially on Win32, will still buffer the output from your
script until it terminates before transmitting the results to the browser.

--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

[Email Removed]


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.