chris_rulez001 Posted May 12, 2007 Share Posted May 12, 2007 hi, its the same script but different problem <?php //fill in some basic info $server = "localhost"; $db_user = ""; $db_pass = ""; $database = "chrisrulez_usersonline"; $timeoutseconds = 300; //get the time $timestamp = time(); $timeout = $timestamp-$timeoutseconds; //connect to database mysql_connect($server, $db_user, $db_pass); //insert the values $insert = mysql_db_query($database, "INSERT INTO useronline VALUES ('$timestamp','{$_SERVER['REMOTE_ADDR']}','{$_SERVER['PHP_SELF']}')"); if(!($insert)) { print "Useronline Insert Failed > "; } //delete values when they leave $delete = mysql_db_query($database, "DELETE FROM useronline WHERE $timestamp<$timeout"); if(!($delete)) { print "Useronline Delete Failed > "; } //grab the results $result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='{$_SERVER['PHP_SELF']}'"); if(!($result)) { print "Useronline Select Error > "; } //number of rows = the number of people online $user = mysql_num_rows($result); //spit out the results mysql_close(); if($user == 1) { print("$user user online\n"); } else { print("$user users online\n"); } ?> //delete values when they leave $delete = mysql_db_query($database, "DELETE FROM useronline WHERE $timestamp<$timeout"); if(!($delete)) { print "Useronline Delete Failed > "; ^ that bit is causing the problem, i think. with the problem the script shows: Useronline Delete Failed > 1 user online i would like it just to show: 1 user online Link to comment https://forums.phpfreaks.com/topic/51108-solved-php-users-online-script/ Share on other sites More sharing options...
MadTechie Posted May 12, 2007 Share Posted May 12, 2007 remove the if(!($delete)) {     print "Useronline Delete Failed > "; } and if(!($result)) {     print "Useronline Select Error > "; } Link to comment https://forums.phpfreaks.com/topic/51108-solved-php-users-online-script/#findComment-251587 Share on other sites More sharing options...
chris_rulez001 Posted May 12, 2007 Author Share Posted May 12, 2007 thanks for your help Link to comment https://forums.phpfreaks.com/topic/51108-solved-php-users-online-script/#findComment-251599 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.