liderbug Posted June 6, 2013 Share Posted June 6, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/ Share on other sites More sharing options...
Jessica Posted June 6, 2013 Share Posted June 6, 2013 Everything is a big secret? What on earth does that mean? A. The path of least resistance is don't upgrade PHP. B. The best way to handle sending mail is to use a mailing class or service. There's PHP Mailer, Swift Mailer, etc etc. Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434467 Share on other sites More sharing options...
liderbug Posted June 6, 2013 Author Share Posted June 6, 2013 ... 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 Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434490 Share on other sites More sharing options...
kicken Posted June 6, 2013 Share Posted June 6, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434568 Share on other sites More sharing options...
liderbug Posted June 7, 2013 Author Share Posted June 7, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434591 Share on other sites More sharing options...
liderbug Posted June 7, 2013 Author Share Posted June 7, 2013 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.. Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434592 Share on other sites More sharing options...
liderbug Posted June 7, 2013 Author Share Posted June 7, 2013 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...... Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434593 Share on other sites More sharing options...
trq Posted June 7, 2013 Share Posted June 7, 2013 Sounds like you need to look into web sockets or similar. Http alone is really designed to do what you your trying to do. It was only luck it ever worked in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/278844-flush-quit-working/#findComment-1434645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.