far2slow Posted November 6, 2012 Share Posted November 6, 2012 I am calling members gamer tags out of the database and then passing them to xbox live to get there online status. the problem i have is I cant pull more than about 10 at a time or it times out i dont have the option of increasing the time out limit, $result = mysql_query ("SELECT id_member, gamer_xbgt FROM smf_members"); while($row = mysql_fetch_array($result)) { $gamertag = $row['gamer_xbgt']; if (!empty($gamertag)) { $html = file_get_html ('https://live.xbox.com/en-US/Profile?Gamertag=' . urlencode ($gamertag)); foreach ($html->find('div[class=presence] ') as $e) echo $row['id_member'] . " " . $gamertag . " " . $e->innertext; echo "<br />"; } } what would be the best solution to solve timeout problems, Quote Link to comment https://forums.phpfreaks.com/topic/270354-script-time-out/ Share on other sites More sharing options...
MMDE Posted November 6, 2012 Share Posted November 6, 2012 set_time_limit($seconds); If you are going to do this very often, then I bet ms won't be too happy about it. I hope you cache the data and only update every x hour or so. While fetching the data you should be nice to the server, only send a request every x second. sleep($seconds); ^ That allows your script to sleep. Remember whenever you sleep you should make the time limit a bit larger. So basically you should create a function that will run after each fetch which adds the delay time and the extra time it takes for the new fetch. Quote Link to comment https://forums.phpfreaks.com/topic/270354-script-time-out/#findComment-1390524 Share on other sites More sharing options...
far2slow Posted November 6, 2012 Author Share Posted November 6, 2012 I will only be running this twice a day and yes i will be caching the data i can not use set_time_limit due to the system policy of our host so is there another way this can be done maybe do it in chunks at a time ? Quote Link to comment https://forums.phpfreaks.com/topic/270354-script-time-out/#findComment-1390538 Share on other sites More sharing options...
MMDE Posted November 6, 2012 Share Posted November 6, 2012 (edited) I will only be running this twice a day and yes i will be caching the data i can not use set_time_limit due to the system policy of our host so is there another way this can be done maybe do it in chunks at a time ? You can do it chunks at a time if you'd like. It could be a page that require some GET data to decide who to update, maybe a "password" to verify it's you it's the script that activated this update. Like this: http://www.example.com/updatescript.php?u=MMDE&pw=somesecretpw updatescript.php file: function update($username){ // your update script } function valid_user($username){ $valid_users = array('MMDE', 'far2slow'); if(in_array($username, $valid_users)) return true; return false; } if(!(!empty($_GET['pw']) && $_GET['pw']=='somesecretpw' && !empty($_GET['u']) && !valid_user($_GET['u']))) exit(); update($_GET['u']); You will need a script that loops through all of the users and visits the site with the appropriate get values in the url. I don't think you can use cURL for this, as it will wait for the responds and get that. You just want to initialize the connection. Another solution may also be to fork, but I'm not sure if it gets affected by time limit. Edited November 6, 2012 by MMDE Quote Link to comment https://forums.phpfreaks.com/topic/270354-script-time-out/#findComment-1390557 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.