Page 1 of 1

Users Online User-defined tag

Posted: Tue Jan 10, 2006 1:52 am
by outdoorxtreme1
I'm trying to get a {usersonline} tag to work properly. It only shows 1 user online even when there are multiple users online. This script worked properly as an include on a page before I had CMS. Can someone help me. Here is the script. Thanks!


$timestamp=time();                                                                                           
$timeout=$timestamp-$timeoutseconds; 
mysql_connect($server, $db_user, $db_pass) or die ("Useronline Database CONNECT Error");                                                                 
mysql_db_query($database, "INSERT INTO onlyusers VALUES ('$timestamp','$REMOTE_ADDR','$PHP_SELF')") or die("Useronline Database INSERT Error");
mysql_db_query($database, "DELETE FROM onlyusers WHERE timestamp
$online user online";} else {echo "$online users online";}

Re: Users Online User-defined tag

Posted: Tue Jan 10, 2006 12:09 pm
by outdoorxtreme1
Could this be because its accessing a different MySQL database than CMS is in?

Re: Users Online User-defined tag

Posted: Tue Jan 10, 2006 5:08 pm
by outdoorxtreme1
Do I need to put these database connection variables in a user defined tag? Or will it do it thru CMSMS?

$server = "  ";           
$db_user = "  ";                                 
$db_pass = "  ";                                   
$database = "  ";                 

Re: Users Online User-defined tag

Posted: Tue Jan 10, 2006 5:25 pm
by Ted
You need to fill that stuff in.

You CAN use the existing database connection, providing that your tables are in the same database.

Re: Users Online User-defined tag

Posted: Tue Jan 10, 2006 5:41 pm
by outdoorxtreme1
Any idea why the IP and the FILE fields are blank in my database? If I use this script on a test.php page it works fine and I can see values in all 3 fields. If I use the script as a user-defined tag in CMSMS only the timestamp field has data in it and the IP and FILE fileds are empty in my SQL database.

Re: Users Online User-defined tag

Posted: Tue Jan 10, 2006 6:57 pm
by outdoorxtreme1
Do I need to create a custom module since this script posts to its self?

Re: Users Online User-defined tag

Posted: Wed Jan 11, 2006 1:44 am
by outdoorxtreme1
I am able to get data in all my SQL fields if I use a user-defined tag that has this script in it:

include "http://www.neohoutdoors.com/usersonline.php";

The only problem now is that I get my servers dedicated IP address for everyone that is on my page instead of their own.

Any thoughts?

Re: Users Online User-defined tag

Posted: Thu Jan 12, 2006 12:52 am
by iNSiPiD
Could you paste or attach that script please? PHP files can't be downloaded as raw code from URLs.