Professional Web Applications Themes

Echoing statements during loop - PHP Development

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...

  1. #1

    Default Echoing statements during loop

    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
    Nick Guest

  2. #2

    Default Re: Echoing statements during loop

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

    Nick Weisser wrote: 
    Exyle Guest

  3. #3

    Default Re: Echoing statements during loop

    "Nick Weisser" <freemails.ch> kirjoitti
    viestissä:42b04e49$bluewin.ch... 


    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

    com


    Kimmo Guest

Similar Threads

  1. echoing PHP code from a database?
    By Sugapablo in forum PHP Development
    Replies: 3
    Last Post: September 19th, 11:05 PM
  2. Replies: 2
    Last Post: July 12th, 06:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139