L Posted January 12, 2008 Share Posted January 12, 2008 I want to run a script every ten minutes for updating users online. Can someone tell me how I can do this? Last time I tried it gave me an server error so I'm afraid to try it out again. The script includes files in the directory it will be in so is just the file name good for an include? Thanks for your time, ~L Quote Link to comment Share on other sites More sharing options...
snk Posted January 12, 2008 Share Posted January 12, 2008 I would like to know as well, if you find out, please post it here thx Quote Link to comment Share on other sites More sharing options...
asmith Posted January 12, 2008 Share Posted January 12, 2008 take a look at these : http://www.phpfreaks.com/forums/index.php/topic,175234.0.html http://www.phpfreaks.com/forums/index.php/topic,175237.0.html I would like to know as well, if you find out, please post it here thanks if someone answers him you can check his thread to find out ,so never post such a thing . the reason i'm asking you about this is so many people when see a thread has a reply , do not read that thread , they search for threads with 0 replies, so you just decrease the chance of his thread to be answered . ( no offense) Quote Link to comment Share on other sites More sharing options...
snk Posted January 12, 2008 Share Posted January 12, 2008 There are people that find the solution but never come back to post. But it seems that it has never happened to you, I am the only unlucky here. Thx for links Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted January 12, 2008 Share Posted January 12, 2008 easy peasy, cron job isn't required for this. just a sec, I'll find the script I use. EDIT: script: <?php /* * TG WHO'S ONLINE * Copyright 2005 - 2006 (c) TOXIC GOBLIN * http://www.toxicgoblin.com * */ //Optional Database Connection Information //**Uncomment the following 2 lines and edit the values if you do not already have an active database connection** // //$db = mysql_connect("localhost", "username", "password") or die("Could not connect"); //mysql_select_db("database_name"); //Fetch Time $timestamp = time(); $timeout = $timestamp - 900; //Insert User $insert = mysql_query("INSERT INTO TG_whos_online (timestamp, ip, file) VALUES('$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."')") or die("Error in who's online insert query!"); //Delete Users $delete = mysql_query("DELETE FROM TG_whos_online WHERE timestamp<$timeout") or die("Error in who's online delete query!"); //Fetch Users Online $result = mysql_query("SELECT DISTINCT ip FROM TG_whos_online") or die("Error in who's online result query!"); $users = mysql_num_rows($result); //Show Who's Online if($users == 1) { print("$users User Online.\n"); } else { print("$users Users Online.\n"); } ?> and here is the MySQL table you need setup: /** * * TG WHO'S ONLINE * Copyright 2005 - 2006 © TOXIC GOBLIN * http://www.toxicgoblin.com * */ /* This is the database creation SQL. You will need to create this table in your MySQL database. */ CREATE TABLE `TG_whos_online` ( `id` bigint(20) NOT NULL auto_increment, `timestamp` int(15) NOT NULL default '0', `ip` varchar(40) NOT NULL default '', `file` varchar(100) NOT NULL default '', PRIMARY KEY (`id`), KEY `ip` (`ip`), KEY `file` (`file`), KEY `timestamp` (`timestamp`) ) TYPE=MyISAM; Regards ACE Quote Link to comment Share on other sites More sharing options...
L Posted January 12, 2008 Author Share Posted January 12, 2008 Idk. I heard that you wouldn't want live stats because once the stats gets bigger it takes longer to load. For example a site my friend had had live stats, but it was so slow because it had over 700 members. So I just wanted to go the safe route with cron jobs, but last time I tried the server started messing up on me so I was wondering if someone knew how to do it correctly Thanks for the threads! Lastly, does the php file that is to be run need to be modified in anyway? Like how would an include look like...would it just be normal? Quote Link to comment Share on other sites More sharing options...
Lamez Posted January 12, 2008 Share Posted January 12, 2008 I have a online script, it tells when I am online, or any other user I set using my variables, and it also tells how many guest are online, and such want it? you can see it here: www.lamezz.com (in the top left corner) and here: www.lamezz.com/user/viewmembers.php Quote Link to comment Share on other sites More sharing options...
L Posted January 12, 2008 Author Share Posted January 12, 2008 If it involves cron jobs, then I'd be glad to! But I already have the script all made and everything...I just need an example of what an executable cron job script looks like so I can make sure no errors come up Quote Link to comment 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.