title: PHP Error: ob_flush() [ref.outcontrol]: failed to flush buffer. No buffer to flush
body: <p>Could someone please save these 2 files and run them and tell me why I get the error " ob_flush() [ref.outcontrol]: failed to flush buffer. No buffer to flush". I tried googling around and it says that I have to use ob_start(); but when I do then it doesn't print out line by line, but rather returns the whole object from the FOR loop when it has completed. I'm kinda new to PHP so I'm not sure where else to look..</p>
  
  <p><strong>test_process.php</strong></p>
  
  <pre><code>// This script will write numbers from 1 to 100 into file
  // And sends continuously info to user
  $fp = fopen( '/tmp/output.txt', 'w') or die('Failed to open');
  set_time_limit( 120);
  ignore_user_abort(true);
  
  for( $i = 0; $i &lt; 100; $i++){
      echo "&lt;script type=\"text/javascript\"&gt;parent.document.getElementById( 'foo').innerHTML += 'Line $i&lt;br /&gt;';&lt;/script&gt;";
      echo str_repeat( ' ', 2048);
      flush();
      ob_flush();
      sleep(1);
      fwrite( $fp, "$i\n");
  }
  
  fclose( $fp);
  </code></pre>
  
  <p><strong>main.html</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt;
  
          &lt;style type="text/css" media="screen"&gt;
              .msg{ background:#aaa;padding:.2em; border-bottom:1px #000 solid}
              .new{ background-color:#3B9957;}
              .error{ background-color:#992E36;}
          &lt;/style&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
  
          &lt;iframe id="loadarea" width="1024px" height="768px"&gt;&lt;/iframe&gt;&lt;br /&gt;
          &lt;script&gt;
              function helper() {
                  document.getElementById('loadarea').src = 'test_process.php';
              }
              function kill() {
                  document.getElementById('loadarea').src = '';
              }
          &lt;/script&gt;
  
          &lt;input type="button" onclick="helper()" value="Start"&gt;
          &lt;input type="button" onclick="kill()" value="Stop"&gt;
          &lt;div id="foo"&gt;&lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>