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" <[EMAIL PROTECTED]>
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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to