Rusty3 Posted July 29, 2009 Share Posted July 29, 2009 Why does this: for ($i = 1; $i < 100; $i++) { echo "$i\n"; sleep(1); } gets me a 500?! Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/ Share on other sites More sharing options...
Rusty3 Posted July 29, 2009 Author Share Posted July 29, 2009 BTW, the same happens with ini_set("max_execution_time", 999999); set_time_limit(999999); Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/#findComment-886207 Share on other sites More sharing options...
Rusty3 Posted August 17, 2009 Author Share Posted August 17, 2009 Any clue please? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/#findComment-899716 Share on other sites More sharing options...
oni-kun Posted August 17, 2009 Share Posted August 17, 2009 You're asking the script to execute infinite times.. for ($i = 1; $i <= 100; $i++) { echo "$i<br/>\n"; sleep(1); } Note you will have to use output buffering and flush() if you wish the echo to actually echo each sleep, and not wait 100 seconds before displaying it all. Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/#findComment-899725 Share on other sites More sharing options...
Rusty3 Posted August 17, 2009 Author Share Posted August 17, 2009 Thanks, using flush and changing the php.ini file rather than setting using php seems to have worked... now my problem is the output.... trying everything on php.net/flush You're asking the script to execute infinite times.. for ($i = 1; $i <= 100; $i++) { echo "$i<br/>\n"; sleep(1); } Note you will have to use output buffering and flush() if you wish the echo to actually echo each sleep, and not wait 100 seconds before displaying it all. Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/#findComment-899781 Share on other sites More sharing options...
oni-kun Posted August 17, 2009 Share Posted August 17, 2009 if (ob_get_level() == 0) ob_start();//place this at top of page for ($i = 1; $i <= 100; $i++) { echo "$i<br/>\n"; echo str_pad('',4096)."\n"; ob_flush(); flush(); sleep(1); } ob_end_flush(); Try this Doesn't require any changing of php.ini settings. Quote Link to comment https://forums.phpfreaks.com/topic/168023-500-internal-server-error/#findComment-899795 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.