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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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