Bluehost.com Web Hosting $6.95

Re: [PHP] timestamp

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-22-2003
John Taylor-Johnston
 
Posts: n/a
Default Re: [PHP] timestamp

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. \");";

Reply With Quote
  #2 (permalink)  
Old 08-22-2003
John Taylor-Johnston
 
Posts: n/a
Default Re: [PHP] timestamp

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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 01:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0