Jump to content

$time = time(); + MySQL? Doesn't work WTF? Help please.


Technex

Recommended Posts

Hey guys, here's my code:

 

 

 

$ip = $_SERVER['REMOTE_ADDR'];

$time = time();

 

mysql_query("INSERT INTO guests

(ip,lastactive) VALUES('$ip','$time') ");

 

 

 

It's for a online guest counter, could you help me fix it for some reason it won't input lastactive like there's a problem with the PHP time function.

 

Thanks ;).

Well if that's good Mysql practice then okay :).

 

I have another problem :(.

 

lastactive in the users database

 

if(isset($userinfo[id])) {

mysql_query("UPDATE users SET lastactive='$lastactive' WHERE id='$userinfo[id]'");

}

 

It just creates a blank MySql entry.

 

lastactive  varchar(70)  ascii_general_ci      No

I guess thats to say somene is online / offline? 1 being online..

if so i'd suggest using a "Users online within the last 5 minute"

By adding a timestamp every page they view....

 

$time = date("j-m-Y, H:i:s", strtotime("now"));

that to set the time stamp.

 

then use this to check last 5 mins

 

$mins = date("j-m-Y, H:i:s", strtotime("- 5 Minutes"));

mysql_query("SELECT * FROM `users` WHERE `status` < '$mins'");

Sorry redarrow I done a ninja edit on you, I tried to be as fast as I could. I fixed the problem I posted and I changed to another one I had.

 

xyn I have a system like that ;). The only problem is on MySql side. Not very good with Mysql.

 

 

Thanks everyone :).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.