Jump to content

WTF... :-/


xtheonex

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
Link to comment
https://forums.phpfreaks.com/topic/8678-wtf/
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]
Link to comment
https://forums.phpfreaks.com/topic/8678-wtf/#findComment-31951
Share on other sites

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.