Jump to content

Archived

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

xtheonex

WTF... :-/

Recommended Posts

[code]session_start();
header("Cache-control: private");
mysql_connect("localhost", "******", "*******") or die (mysql_error());
mysql_select_db("local") or die (mysql_error());
if(!session_is_registered('online')){
    mysql_query("INSERT INTO ppl_online (session_id, activity) VALUES ('\".session_id().\"', now()") or die (mysql_error());
    session_register('online');
}
if(session_is_registered('online')){        
    mysql_query("UPDATE ppl_online SET activity=now() WHERE session_id=\".session_id().\"") or die (mysql_error());
}
$limit_time = time() - 300; // 5 Minute time out. 60 * 5 = 300
$sql = mysql_query("SELECT * FROM ppl_online WHERE UNIX_TIMESTAMP(activity) >= $limit_time") or die (mysql_error());
$visits = mysql_num_rows($sql);
?>[/code]

Why the buggery aint this working?
It registers the session variable "online" as null yet doesnt add anything to the database :-/

Any help would be grateful guys.

Thanks in advance,
Dave

Share this post


Link to post
Share on other sites
Have you read

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63200\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63200[/a]

Share this post


Link to post
Share on other sites
The reason why your sessions are being set with null values is because you aren't sertting a value for the sessions. You are doing:
[code]<?php

....

session_resigter("design");

?>[/code]and thats it!

That will create the design session variable but wont a set value to the session. To set the valye to the design session variable you do this:
[code]$_SESSION['design'] = "someValue";[/code]or if yo uhave register globals on you'll do this:
[code]$design = "someValue";[/code]

Aslo your SQL query are alittle wrong too it shoudl be this:
[code]mysql_query("INSERT INTO ppl_online (session_id, activity) VALUES ('".session_id()."', now()") or die (mysql_error());[/code]

Share this post


Link to post
Share on other sites

×

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.