shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 change row['id'] to $row['memberid'] Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237506 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 line 552 is missing a ) Â yes.. Ok.. Â echo "ID = $id"; //Added for debugging $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `surv_member` SET timestamp='$time' WHERE memberId='$id' LIMIT 1"); $query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp`>='$timeout'") or die(mysql_error()); $display = array(); while($row=mysql_fetch_array($query)) { $display[] = $row['username']; } //spit out the results mysql_close(); foreach($display as $d) { print "$d<br />"; } Â gives me ID = Â Â that's it. Â Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237507 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 OK $id isn't being set, Â do you know what the user's id is ? Â Â Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237510 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 Â change row['id'] to $row['memberid'] Â That didn't change anything because I beleive it's the syntax Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237511 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 but you dnt have an `id` column in your db, it's memberid, have u tried it? did it return the same error? Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237512 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 to fix shaunrigby script up data to this  $query = mysql_query("SELECT * FROM `surv_member` WHERE `online`= '1' AND `timestamp` >= '" . $timeout . "'") or die("SELECT Stament: " . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237514 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 what did u change? Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237515 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 OK $id isn't being set, Â do you know what the user's id is ? Â Â Â Â the user's id should be memberId Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237518 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 i don't mean from the database..  i don't have the infomation required to compleate the script..  ok just guessing here but can you do a echo "session=" print_r($_SESSION); echo "GET=" print_r($_GET); echo "POST=" print_r($_POST); and give me the output please  Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237520 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 change row['id'] to $row['memberid'] Â correct it to memberId so it would read $row['memberId'] your program is underlining that "$row" so it is telling you that the error is that (i think) Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237521 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007  Ok with Madtechie's syntax correction we have this  //Shaun script $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `username` SET `timestamp` = '" . $time . "' WHERE `memberId` = '" . $id . "' LIMIT 1") or die("Update Query 1: " . mysql_error()); $query = mysql_query("SELECT * FROM `surv_member` WHERE `online`= '1' AND `timestamp` >= '" . $timeout . "'") or die("SELECT Stament: " . mysql_error()); while($row=mysql_fetch_array($query)){   mysql_query("UPDATE `username` SET `online` = '0' WHERE `memberId` = '" . $row['memberId'] . "' LIMIT 1") or die("Update Query 2: " . mysql_error()); print $row['online']; } mysql_close();  Output: Update Query 1: Table 'survtask.username' doesn't exist Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237522 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 change your updates to: ("UPDATE `surv_member` Â D'OH! Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237525 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 i don't mean from the database..  i don't have the infomation required to compleate the script..  ok just guessing here but can you do a echo "session=" print_r($_SESSION); echo "GET=" print_r($_GET); echo "POST=" print_r($_POST); and give me the output please    <?php echo "session=" print_r($_SESSION); echo "GET=" print_r($_GET); echo "POST=" print_r($_POST); ?>  Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\sb\index.php on line 591  591 is the print_r($_SESSION); Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237528 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 oh my  dang ;  try <?php echo "session="; print_r($_SESSION); echo "GET="; print_r($_GET); echo "POST="; print_r($_POST); ?> Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237529 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 ad ; after the 2 echo's Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237530 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 change your updates to: ("UPDATE `surv_member` Â D'OH! Â //Shaun script $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `surv_member` SET `timestamp` = '" . $time . "' WHERE `memberId` = '" . $id . "' LIMIT 1") or die("Update Query 1: " . mysql_error()); $query = mysql_query("SELECT * FROM `surv_member` WHERE `online`= '1' AND `timestamp` >= '" . $timeout . "'") or die("SELECT Stament: " . mysql_error()); while($row=mysql_fetch_array($query)){ Â Â mysql_query("UPDATE `surv_member` SET `online` = '0' WHERE `memberId` = '" . $row['memberId'] . "' LIMIT 1") or die("Update Query 2: " . mysql_error()); print $row['online']; } mysql_close(); Â gives me no error. no output Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237532 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 has it updated your tables tho? Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237535 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 oh my  dang ;  try <?php echo "session="; print_r($_SESSION); echo "GET="; print_r($_GET); echo "POST="; print_r($_POST); ?>   session=Array ( [s:5:"admin";tznUserLastLogin] => 2007-04-24 13:38:16 [tznUserLastAddress] => 127.0.0.1 [linkItems] => index.php?sUser=0&show=today&sort=deadlineDate&dir=1 [tznUserId] => 1 [tznUserLevel] => 4 [tznUserTimeZone] => -18000 ) GET=Array ( [phpSESSID] => 2b2225a5e894f61e62d8bf56de6e1848 ) POST=Array ( )   Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237537 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 cool <?php $id = $_SESSION['tznUserId']; $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `surv_member` SET timestamp='$time' WHERE memberId='$id' LIMIT 1"); $query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp`>='$timeout'") or die(mysql_error()); $display = array(); while($row=mysql_fetch_array($query)) { $display[] = $row['username']; } //spit out the results mysql_close(); foreach($display as $d) { print "$d<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237541 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 has it updated your tables tho? Â I don't think it did update the table. I browse the field and there's nothing in it. Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237543 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 cool <?php $id = $_SESSION['tznUserId']; $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `surv_member` SET timestamp='$time' WHERE memberId='$id' LIMIT 1"); $query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp`>='$timeout'") or die(mysql_error()); $display = array(); while($row=mysql_fetch_array($query)) { $display[] = $row['username']; } //spit out the results mysql_close(); foreach($display as $d) { print "$d<br />"; } ?>  added this in the index.php and it didn't output any error or message  Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237545 Share on other sites More sharing options...
shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 where does $Id come from? Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237546 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 this is so much easier working directly  ok updated (again)  <?php $id = $_SESSION['tznUserId']; $time=time(); $timeout=time()+(60*60); #now+1hour mysql_query("UPDATE `surv_member` SET timestamp='$timeout' WHERE memberId='$id' LIMIT 1"); $query=mysql_query("SELECT * FROM `surv_member` WHERE `timestamp`>='$time'") or die(mysql_error()); $display = array(); while($row=mysql_fetch_array($query)) { $display[] = $row['username']; } //spit out the results mysql_close(); foreach($display as $d) { print "$d<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237548 Share on other sites More sharing options...
MadTechie Posted April 24, 2007 Share Posted April 24, 2007 to play fair  add $id = $_SESSION['tznUserId'];  to the top of shaunrigby code Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237550 Share on other sites More sharing options...
alohatofu Posted April 24, 2007 Author Share Posted April 24, 2007 where does $Id come from? Â Â $Id ? Â do you mean memberId ? it's under surv_member table Quote Link to comment https://forums.phpfreaks.com/topic/48444-solved-show-users-online/page/3/#findComment-237552 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.