have a script that records hits into a MySQL db using:

PHP:--------------------------------------------------------------------------------
mysql_db_query($database, "INSERT INTO sales VALUES ('$ref', '$clientdate', '$clienttime', '$clientbrowser',
'$clientip', '$payment', '$clienturl')")
or die("Database INSERT Error (line 34)");


However I need the script to check to see if the $ref value AND $clientdate value AND $clientip value are the same, if so dont store.

This way hits sent from the same reffer and using the IP address on the same day or not recorded in the db.

Any ideas?
If you would like to chat about this or would like any more info please email me at andyinorbit2000@yahoo.com

Thanks for any help you can give.
Andy

    alter table sales add unique (ref,clientdate,clientip);

    Of course alter the line above to illustrate your specific fields.

    then when you execute your query...

    if(!($sql = mysql_query("INSERT INTO sales VALUES ('$ref', '$clientdate', '$clienttime', '$clientbrowser', 
    '$clientip', '$payment', '$clienturl')") ))
    {
          echo "sorry entry already exists";
          exit;
    }
    
    

    Also note that mysql_db_query has been depricated with recent versions of php. Its best to start using mysql_query, and declaring your database after your connnection..

    mysql_select_db($D😎;

    Cheers,

    John

      $check = mysql_query("SELECT ref, clientdate, clientip FROM sales WHERE ref='$ref' AND clientdate='$clientdate' AND clientip='$clientip' ");
      $check = mysql_num_rows($check);
      if ($check > 1) {
         echo "entry already exists!";
      } else {
         $insert = mysql_query(" INSERT INTO sales (ref, clientdate, clienttime, clientbrowser, 
      clientip, payment, clienturl) VALUES ('$ref', '$clientdate', '$clienttime', '$clientbrowser', 
      '$clientip', '$payment', '$clienturl') ");
         echo "entry added into the database!";
      }
      
        Write a Reply...