php_b34st Posted April 4, 2013 Share Posted April 4, 2013 Hi, I am trying to loop through all of the users on my site and grab their game stats from another site to do this i am using fopen within a foreach loop, this works nicely for about 30 members but when it gets to 31 i get a time out error. Is there any way to get around this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/ Share on other sites More sharing options...
requinix Posted April 4, 2013 Share Posted April 4, 2013 Increase the timeout. Any reason you have to do them all at once? Can you put off looking up an individual user until you really need it? Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422827 Share on other sites More sharing options...
php_b34st Posted April 4, 2013 Author Share Posted April 4, 2013 How would i increase the timeout? I have to update them all at once because its a clan leader board so it wouldn't work if some users were not updated. Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422828 Share on other sites More sharing options...
requinix Posted April 4, 2013 Share Posted April 4, 2013 set_time_limit Are you running this from a cronjob? You should be. Apparently this takes too long to be suitable for doing during a normal page load. Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422835 Share on other sites More sharing options...
php_b34st Posted April 4, 2013 Author Share Posted April 4, 2013 No I'm not using a cronjob as I'm using a free server and i don't think they support cronjob. Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422843 Share on other sites More sharing options...
php_b34st Posted April 4, 2013 Author Share Posted April 4, 2013 I have just tried using set_time_limit however my host has this feature disabled. Is there any other way around this? Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422865 Share on other sites More sharing options...
Technocrat Posted April 4, 2013 Share Posted April 4, 2013 What is already suggested is probably the best options. Though you could use some of the ideas I posted here: http://forums.phpfreaks.com/topic/274233-moving-files-with-php/ Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422883 Share on other sites More sharing options...
Solution php_b34st Posted April 4, 2013 Author Solution Share Posted April 4, 2013 I have managed to get it to work using max_execution_time instead of set_time_limit Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/276517-using-fopen-within-a-loop/#findComment-1422911 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.