shaunrigby Posted April 24, 2007 Share Posted April 24, 2007 change row['id'] to $row['memberid'] 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. 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 ? 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 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? 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()); 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? 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 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 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) 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 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! 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); 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); ?> 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 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 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? 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 ( ) 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 />"; } ?> 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. 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 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? 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 />"; } ?> 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 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 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
Archived
This topic is now archived and is closed to further replies.