xtheonex Posted April 28, 2006 Share Posted April 28, 2006 [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 More sharing options...
Barand Posted April 29, 2006 Share Posted April 29, 2006 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] Link to comment https://forums.phpfreaks.com/topic/8678-wtf/#findComment-31908 Share on other sites More sharing options...
wildteen88 Posted April 29, 2006 Share Posted April 29, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.