Jump to content


WTF... :-/

  • Please log in to reply
2 replies to this topic

#1 xtheonex

  • New Members
  • Pip
  • Newbie
  • 8 posts
  • LocationBurton-Upon-Trent, Staffordshire, UK

Posted 28 April 2006 - 10:58 PM

header("Cache-control: private");
mysql_connect("localhost", "******", "*******") or die (mysql_error());
mysql_select_db("local") or die (mysql_error());
    mysql_query("INSERT INTO ppl_online (session_id, activity) VALUES ('\".session_id().\"', now()") or die (mysql_error());
    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);

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,

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 29 April 2006 - 07:30 AM

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]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 29 April 2006 - 02:18 PM

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:



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:
$_SESSION['design'] = "someValue";
or if yo uhave register globals on you'll do this:
$design = "someValue";

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users