Thatar Posted April 19, 2010 Share Posted April 19, 2010 Hello guys, I had made a nice little script, and suddenly out of nowhere came this stupid "Premature end of script headers"error. This is how it looks like in the log: [Tue Apr 20 00:02:50 2010] [warn] mod_fcgid: read data timeout in 40 seconds [Tue Apr 20 00:02:50 2010] [error] [client xx.xxx.xx.xx] Premature end of script headers: buyunit.php, referer: http://www.omnicash.org/cycler/ When you saw this topic you probably thought, Google it! Well I did, and all the things I found say something about having your server set up the wrong way, which is not the case since it only happens on a certain action. Strangely enough the following if-statement seems to be causing the error (even though I can't see anything wrong about it): if($result <= 0) { //Make the negative of $result the new $flow $flow -= $req; //Cycle complete, add one to $topid $topid += 1; //Cycle complete, $done = 1 $done = 1; //Required profit must be added to balance of account $addCyclerBalance = $req; //Requirements have been met, $req = 0 $req = 0; } The whole code is attached to this message, I hope you can do something with it. I just don't have a clue. If you need more information please tell me. Thanks in advance, Herman [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/199071-premature-end-of-script-headers-error/ Share on other sites More sharing options...
premiso Posted April 19, 2010 Share Posted April 19, 2010 Chances are your script is timing out, this is not uncommon, especially when you do multiple whiles inside whiles with updating data in a database. You should try and make your script a bit more efficient and try to move the queries outside of the loop and minimize them if possible. To avoid the issue you can try increasing the timeout with the set_time_limit 0 = never timeout. Default is 30 seconds. It goes by seconds btw. Quote Link to comment https://forums.phpfreaks.com/topic/199071-premature-end-of-script-headers-error/#findComment-1044898 Share on other sites More sharing options...
Thatar Posted April 19, 2010 Author Share Posted April 19, 2010 Thanks for your quick response. Increasing the time-out would be horrible so I will take a better look at the whiles and queries. But I only have one while inside another while, that shouldn't do any bad? Herman Quote Link to comment https://forums.phpfreaks.com/topic/199071-premature-end-of-script-headers-error/#findComment-1044900 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.