PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old December 13th, 2003, 02:26 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
problem with database driven php whos online stats

alright I really can't figure out why this won't work. The biggest issue is that it is a script integrated into a membership tutorial from devarticles that was deleted (it was ben rowes old script, I believe). well the online function doesn't work! It seems to be adding users as they are there, and deleting them as a new one is added, and I don't understand why. So it always says one user online/0 guests... and I'm always the current user at the site. I have other users tell me they experience the same issue... I thought it may have been that it deletes the user from online if there are one or less users on the site (and that seems like a flaw since wouldn't it never reach two users..?) but if I get rid of that code it doesn't remove them from online... I hope this is understandable enough.
well i could post the php here, but I fear it would be too long, so how about a zip file.... and then i shall dump my db table.

PHP Code:
# Table structure for table `online`
#
# Creation: Dec 13, 2003 at 12:09 AM
# Last update: Dec 13, 2003 at 12:09 AM
#

CREATE TABLE `online` (
  `
idint(14NOT NULL auto_increment,
  `
userIPvarchar(20NOT NULL default '',
  `
dateAddedtimestamp(14NOT NULL,
  `
userIdint(14NOT NULL default '0',
  `
userNamevarchar(20NOT NULL default '',
  
PRIMARY KEY  (`id`)
TYPE=MyISAM
Attached Files
File Type: zip online.zip (4.1 KB, 456 views)
__________________
hey it's the CHARKING

Reply With Quote
  #2  
Old December 25th, 2003, 02:16 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
any help?

Reply With Quote
  #3  
Old December 29th, 2003, 07:45 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I'd consider getting rid of the if $show <=1 and changing the deletion so that it deletes where session time is greater than the timeout. This'd keep the db clean without causing the problem you note.

Reply With Quote
  #4  
Old December 29th, 2003, 03:35 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
thank you for your help! this has been bothering me sooo much and I knew that was the problem but when I took that away it simply kept building the database up, anway, is this what would work?

PHP Code:
if(SESSION_LENGTH >= $timemax)
    {

        
//if there is one or less visitors online, then we will delete the database, to keep the number of enteries down
        
@mysql_query("DELETE FROM online");

    } 

Reply With Quote
  #5  
Old December 29th, 2003, 04:56 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
wait SESSION_LENGTH is a constant variable isn't it... so that won't work will it... would I jsut write if($_SESSION >= $timemax)?
I am not too familiar with sessions

Reply With Quote
  #6  
Old December 30th, 2003, 08:03 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Looks like $timeMax is being set to now minus SESSION_LENGTH (currently 20 minutes), so you'd need to delete from online where dateAdded is less than $timeMax. I think I've got that right -- I always get turned around when screwing with dates like this. To test, just set SESSION_LENGTH in line 19 to something like .5 or .1 so that the expiration happens a lot more quickly. Then keep hitting pages and seeing if your hits drop out.

Reply With Quote
  #7  
Old December 31st, 2003, 04:23 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
Oh yes, I thought that that was what I needed... would this do?
PHP Code:
 mysql_query("DELETE FROM online WHERE unix_timestamp(dateAdded) <= '" $timeMax "'"); 

It seems to be working; and I also noticed I had this code elsewhere in the view who's online page, which may have been causing problems. I'll let you know if I have any more problems, but so far it seems great. thank you.

Reply With Quote
  #8  
Old December 31st, 2003, 06:27 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I think that should work, though you shouldn't need the single quotes around $timeMax, its being a number and all.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > problem with database driven php whos online stats


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway