This is a discussion on Re: [PHP] timestamp within the PHP General forums, part of the PHP Programming Forums category; This is what I'm using so far. But I need to put in a time stamp to calculate if ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. \");"; |
|
|||
|
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 |