Jump to content

[SOLVED] show users online


alohatofu

Recommended Posts

  • Replies 94
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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
Share on other sites

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
Share on other sites

 

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.