ChrisMayhew Posted November 3, 2007 Share Posted November 3, 2007 <?php include('Settings.php'); //Variables $CurrentTime = time(); //$Active = mysql_query("SELECT UserID, Username, Time, Active FROM activeusers "); while ($GetActive = mysql_fetch_array(mysql_query("SELECT UserID, Username, Time, Active FROM activeusers "))) { $UserID = $GetActive['UserID']; $Username = $GetActive['Username']; $Time = $GetActive['Time']; $Active = $GetActive['Active']; If ($Active == '1') { If ($CurrentTime >= $Time) { mysql_query("UPDATE activeusers SET Active = '0' WHERE Username = '$Username' "); } } } ?> Hey I am trying to make a Cron job script, What i would like this to do is go through a table on a database and if the CurrentTime is greater than the Time in the database then set Active to 0. Now when i run this script through a browser it takes forever with the loading, and then gives me this error: Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\Project\includes\ActiveUsersCron.php on line 9 My understanding is that it is getting stuck somewhere on the code, the strange thing is it will process the first row in the table but after this it just stops. Any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/75954-solved-solvedphp-script-kind-of-locking-up/ Share on other sites More sharing options...
Daukan Posted November 3, 2007 Share Posted November 3, 2007 Execute the query first <?php $query = "SELECT UserID, Username, Time, Active FROM activeusers "; $stm = mysql_query($query); while ($GetActive = mysql_fetch_array($stm) ) { snip... ?> Quote Link to comment https://forums.phpfreaks.com/topic/75954-solved-solvedphp-script-kind-of-locking-up/#findComment-384431 Share on other sites More sharing options...
ChrisMayhew Posted November 3, 2007 Author Share Posted November 3, 2007 Execute the query first <?php $query = "SELECT UserID, Username, Time, Active FROM activeusers "; $stm = mysql_query($query); while ($GetActive = mysql_fetch_array($stm) ) { snip... ?> That did the trick That has been bugging me for about the last hour and a half. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/75954-solved-solvedphp-script-kind-of-locking-up/#findComment-384434 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.