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] Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/ 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283231 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 Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283234 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283235 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283238 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? Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283241 Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 varchar is the field Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283252 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283257 Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 it returns no errors Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283268 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283287 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283296 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? Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283425 Share on other sites More sharing options...
corillo181 Posted June 26, 2007 Author Share Posted June 26, 2007 255 unsigned Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283429 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283441 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. Link to comment https://forums.phpfreaks.com/topic/57296-referer-url/#findComment-283444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.