Re: newbie - problems with Select and timestamp(14) calculation
| From: | p.whiter | Date: | Fri, 19 Oct 2001 10:48:52 +0000 |
| Subject: | Re: newbie - problems with Select and timestamp(14) calculation | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13528@lists.php.net to get a copy of this message | ||
Finally this is working as required!! I ended up changing the column type
that stores the time to an INT and inserting a UNIX TIMESTAMP into it, below
is the code that works fine, it may be useful to somebody else as a flood
control, I hope it is fairly self-explanatory....
/***Variable to insert UNIX_TIMESTAMP into DB first time round***
****column for time is INT UNSIGNED NOT NULL*********************/
$pw_time = time ();
/***************************/
//users current IP
$pw_userIP = getenv("REMOTE_ADDR");
$sql = "SELECT (UNIX_TIMESTAMP() - log_time) AS timediff FROM clinic_log
WHERE user_ip = '$pw_userIP' ";
$sql_result = mysql_query($sql,$connection) or die("Couldn't execute
query");
if (mysql_num_rows($sql_result)!=0)
{
while($row = mysql_fetch_array($sql_result))
{
if($row[timediff]<360) //**number of seconds to block resubmission
{
die("<b>ERROR:</b> Your question has already been submitted.");
} } }
************************************************************
What a frustrating experience it was to get this sorted out, still I have
learnt a lot in the process, which is what it's all about I guess!
Thanks again
Paul
----- Original Message -----
From: "p.whiter" <p.whiter@0800dial.com>
Subject: Re: [PHP-DB] newbie - problems with Select and timestamp(14)
calculation
: Thanks to everyone for your help!!
:
: I have plenty to try here, I'll let you know how I get on with it....
:
: Regards
: Paul