Jump to content

[SOLVED] [Solved]PHP Script Kind of Locking Up.


ChrisMayhew

Recommended Posts

<?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

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 :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.