Re: timestamp

From: Date: Fri, 22 Aug 2003 17:46:53 +0000
Subject: Re: timestamp
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-160431@lists.php.net to get a copy of this message
Anyone? Please :) John Taylor-Johnston wrote: > This is what I'm using so far. But I need to put in a time stamp to calculate if the > visitor is new. I want to use the IP so if the ip saved in MySQL is older than 60 minutes, it will > write a new record, if not, don't: > > $myconnection = mysql_connect($server,$user,$pass); > mysql_select_db($db,$myconnection); > > $getaddr = $_SERVER['REMOTE_ADDR']; > $gethost = gethostbyaddr($_SERVER['REMOTE_ADDR']); > $EntryDate = date("Y-m-d"); > > $sql = "INSERT INTO $table (IPAddress,RemoteHost,EntryDate) > values('$getaddr','$gethost','$EntryDate')"; > mysql_query($sql); > > $myconnection = mysql_connect($server,$user,$pass); > mysql_select_db($db,$myconnection); > $result = mysql_query("SELECT * FROM $table", $myconnection); > $num_rows = mysql_num_rows($result); > > echo "document.write(\"$num_rows visitors. \");"; -- John Taylor-Johnston ----------------------------------------------------------------------------- "If it's not open-source, it's Murphy's Law." ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064

« previous php.general (#160431) next »