corillo181 Posted June 26, 2007 Share Posted June 26, 2007 why every thing is set into the table but not the refere url... i got this code in all the pages. <?php $reff=$_SERVER['HTTP_REFERER']; if(!isset($_SESSION['online'])){ mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')"); $_SESSION['online']="online"; }else{ if(isset($_SESSION['user_id'])){ @mysql_query("UPDATE online SET activity=now(), member='y' WHERE session_id='".session_id()."'"); } } if(isset($_SESSION['online'])){ @mysql_query("UPDATE online SET activity=now() AND refurl='$reff' WHERE session_id='".session_id()."'"); } ?> [code] [/code] Quote Link to comment Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 Spelling it right can help: $reff=$_SERVER['HTTP_REFERRER']; Also on a side note, that field may not always be populated or correct as it is sent by the client. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 the php manual says is only one r Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 26, 2007 Share Posted June 26, 2007 Spelling it right can help: $reff=$_SERVER['HTTP_REFERRER']; Also on a side note, that field may not always be populated or correct as it is sent by the client. Actually the Manuel has it spelled "HTTP_REFERER" http://www.php.net/manual/en/reserved.variables.php EDIT: Beat to it Frost is probably right about it just not being populated. Try echoing to the screen to see if it prints anything. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 also if i try to echo $reff it does echo the previous page, but when i try to insert it into mysql it doesn't populate at all and every field is set correctly. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 26, 2007 Share Posted June 26, 2007 Try changing this line: mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')"); To this: mysql_query("INSERT INTO online(session_id,activity, ip_address, refurl, user_agent)VALUES('".session_id()."','now()','".$_SERVER['REMOTE_ADDR']."','".$reff."','".$_SERVER['HTTP_USER_AGENT']."')")or die(mysql_eror()); What field type do you have the column set to in the database? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 varchar is the field Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted June 26, 2007 Share Posted June 26, 2007 Did you try the query I gave you? That should return the error. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 it returns no errors Quote Link to comment Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 The problem is in the update query. <?php if(isset($_SESSION['online'])){ mysql_query("UPDATE online SET activity=now(), refurl='$reff' WHERE session_id='".session_id()."'") or die(mysql_error()); } I highly suggest not using those @ symbols, they screw you up especially when you are trying to fix something that is broken. The update query does not use AND it takes a comma to separate fields. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 yeah i removed it jus tnot, but the reff stills echo out on the page, but it does not goes into mysql. Quote Link to comment Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 What is the size of the varchar field? Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 255 unsigned Quote Link to comment Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 The unsigned part is the error, it is expected a numeric type data. Change it to not be unsigned and try it again. Quote Link to comment Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 no my bad is not unsigned.. lol i looked at the wrong column every thing is properly formatted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.