Jump to content

Recommended Posts

Did a search - nothing.  I did find a reference on the web that > php 5.2.? (or some such number) that flush no longer works.  I need a workaround.

 

I send out a weekly email to about 180 via a relay host.  In the past the code was a loop of:

...

mail ($to...

flush();

 

Worked great, warm fuzzies, bad addresses JUMPED right out - life was good.  Now everything is a big secret and if something goes wrong ...

 

1. Is flush coming back?

2. Assuming I'm not the first - an all ready written peice of code?

3. Suggestions?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/
Share on other sites

... big secret - means nothing shows up.  I click on the "OK to send" button and ............ nothing,  Two or three minutes later still a blank screen.  [shhhhhh... it's a secret what the server did.]

 

I am using  

         require_once "Mail.php";
         include_once 'Mail/mime.php' ;
         include "thisweeksmail.php";  Mysql DB, select email from table where...

         $mail = $smtp->send($to, $headers, $body); 

         check for OK/Err and output to screen  (what'ya mean tomnjanemsn.com - so what's wrong with that?????)

 

"... don't upgrade..."  Wasn't my call, my hosting company did it.  - Just spent 20 minutes trying to find if I can "setversion [oldervers];  no luck.

 

I guess I could rewrite the whole thing to run off-line, output to a file, mail file to me after.  But then sort'a not the point. - What wasn't broken has now been fixed.  And several times I've found flush (); to be such a nice feature - not so much for me but for who I wrote the page/script for - "Hey, I clicked on the 'GO' button and nothing happened."  "Well ya, it takes 10-20 seconds for the first of 100 lines to show up."  "Why?"  <sigh>

 

 

Chuck

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434490
Share on other sites

Try calling ob_flush in addition to flush. Also be aware that there could always be additional buffers between you and the script which you have no control over. For example another apache module (eg mod_gzip), a proxy server, your browser...

 

If you want to have continuous output then flush isn't really the appropriate approach. A more appropriate approach would be to split the job into several small batches and use some AJAX or simple page refreshing to execute each batch and update the screen.

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434568
Share on other sites

Found this in my searches  (is sort of hidden - well just not waving a flag...)

 

http://us1.php.net/manual/en/function.ob-flush.php    

 

5 Lee  9 months ago As of August 2012, all browsers seem to show an all-or-nothing approach to buffering. In other words, while php is operating, no content can be shown.

 

Looks like I'm toasted

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434591
Share on other sites

However, checking to see is anything was posted later I found cesoid at gmail dot com about 3/4 down the page (aside, why is nothing in time order???)

 

<?php
  ob_implicit_flush
();
 
ob_end_flush();
 
?><body>[1013 more characters]<?php
 
for ($i = 1; $i < 30000000; ++$i) {}
  echo
"something that didn't show up immediately";
?>

and this works - so I modified it:

 

$list = array ("email1", em2, 3 4 5...);

foreach ($list as $li) {

echo "$li<br>";

sleep (1);  #to simulate sending an email to my relay host

}

 

and I get

email1 (pause...

em2 (pause....

3 (pause

back in business.

 

WT.......?????

 

Hmmm, works local (home box) but not on server (east coast) more playing around - a php.ini difference...  ??

 

More when I figure it out..

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434592
Share on other sites

I'm stumped!  My box at home runs the above code just fine. PHP = 5.3.20.  The same code on the hosting box runs a blank screen until all done then outputs   everthing at one time.  PHP = 5.2.17.  I've tried to compair the 2 php.ini files - apples-n-oranges.  Maybe it a version thing and 5.3 works.  I've asked my hosting company to see if it runs on a 5.3 box - if they have any. 

 

Guess I could transfer the email send function to my home puter......

Link to comment
https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434593
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.