Quote:
Originally Posted by MoForce
is there a way to get the IPs into an array to fix that or is there another solution to this problem?
|
That would suggest to me, that their are no IP's to delete. *Adds debugger
PHP Code:
require ("config.php"); $timeoutseconds = 10; // length of session $timestamp=time(); $timeout=$timestamp-$timeoutseconds;
$query = mysql_query("SELECT ip FROM useronline WHERE timestamp<$timeout"); while($row = mysql_fetch_array($query)){ $ips_to_remove[] = $row['ip']; // Store the IP. //mysql_query("DELETE FROM users WHERE ip='".$row['ip']."'") or die(mysql_error()); } if(is_array($ips_to_remove ){foreach($ips_to_remove as $value){ // Do the query here one after the other. mysql_query("DELETE FROM users WHERE ip='".$value."'") or die(mysql_error()); usleep(5000000); // Wait 5 seconds, this stops you over loading your server. }} else {echo "Nothing to remove.";}
Quote:
Originally Posted by CouponGuy
Yes, putting mysql queries inside a while loop should work. Also, you could put the query inside the same sql statement (I'm guessing you may have done this already).
SQL:
Code:
DELETE FROM users where ip IN (
SELECT ip FROM useronline WHERE timestamp<$timeout
)
|
I was thinking that, but the details are in different tables.
__________________
My Blog/Site: Please login or register to view this content. Registration is FREE
Last edited by rogem002; 11-13-2008 at 07:38 AM..
|