Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple Problem - Who's Online
Old 09-23-2005, 06:36 PM Simple Problem - Who's Online
Skilled Talker

Posts: 64
Trades: 0
PHP Code:
<?
$currenttime
=date("U");
$endtime=$currenttime-60;

$query55689="DELETE FROM members_online WHERE time < $endtime";
$result55689=mysql_query($query55689);

if (
$userlevel) {
$query55699="SELECT user FROM members_online WHERE user='$cookieuname'";
$result55699=mysql_query($query55699);
$num55699=mysql_num_rows($result55699);

if (
$num55699 == '0') {
$query55="INSERT INTO members_online (user, time) VALUES ('" $cookieuname "', '" $currenttime "')";
$result55=mysql_query($query55);
} else {
$query2888="UPDATE members_online SET time = '$currenttime' WHERE user ='$cookiename'";
$result2888=mysql_query($query2888);
}}
?>
I'm making a 'Who's Online' system.
Basically what this script does first of all is deletes anyone from the 'members_online' table who haven't moved for the past 60 seconds (yes I know its a short time, ignore it). After it's done that it goes onto the user in hand.

- It gets the username stored in the cookie and searches for it in the 'members_online' table.
- If there are no names like that in the table, it will create a new one with a new time
- If there is, it'll simply update their time.

However this does not seem to be working. I opened my page once and the info went into the database perfectly, however when I refreshed or browsed my site, I noticed my time was not updating. Why is this?

Extra Notes: Variables '$cookieuname' and '$userlevel' ARE declared earlier in my script (this is just a snippet). They are definitely declared (and used elsewhere).

EDIT: I've just echoed $num55699 and it works perfectly so I'm guessing that something is wrong with the update section of the script then. Any help appreciated!
Petsmacker is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-23-2005, 11:31 PM
ejumblesale's Avatar
Extreme Talker

Posts: 240
Location: Kent
Trades: 0
Have you tried error checking your update Query?

Set ur errors to show all then when executing the query use:

PHP Code:
if(@mysql_query ($query2888)) {
    echo 
"Updated Succesfully";
 }
else echo 
"Unable to add info".mysql_error()."<br>$query2888"
Also you should check you shouldn't put your 0 in quotes try if ($num55699 == 0).

Ensure you echo your queries while debugging this way you can trace write and may notice a error you didnt think you had.

Hope that helps...
__________________

Please login or register to view this content. Registration is FREE
- The Internet Jumble Sale,

Please login or register to view this content. Registration is FREE
- Personal space containing interesting articles and information on downloadable scripts

Please login or register to view this content. Registration is FREE
- Free link exchange directory and PPC advertising scheme

Please login or register to view this content. Registration is FREE
- The ejumblesale forums
ejumblesale is offline
Reply With Quote
View Public Profile Visit ejumblesale's homepage!
 
Old 09-24-2005, 02:22 AM
Extreme Talker

Posts: 169
Trades: 0
Quote:
$query2888="UPDATE members_online SET time = '$currenttime' WHERE user ='$cookiename'";

The mistake is :
WHERE user ='$cookiename'";

its $cookieuname
__________________

Please login or register to view this content. Registration is FREE

TOP 10 WEB HOSTS COMPARED

BEST RESELLER HOSTING
john551 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple Problem - Who's Online
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11648 seconds with 12 queries