MYSQL Insert: How to save Query in the database only one time - duplicate key doesn't work!

Posted by elmaso on Stack Overflow See other posts from Stack Overflow or by elmaso
Published on 2010-04-17T23:43:31Z Indexed on 2010/04/17 23:53 UTC
Read the original article Hit count: 127

Filed under:
|

hello, I want to save a query only one time in the database, this is my code:

   $querystat = mysql_real_escape_string($_GET['q']);
    $datetime = time();
    if( ($querystat != $_SESSION['prev_search']) OR ( ($datetime - $_SESSION['datetime']) > 60) ) {
    $insertquery = "INSERT INTO `query` ( `searchquery` , `datetime`) VALUES ( '$querystat' , '$datetime') ON DUPLICATE KEY UPDATE searchquery='$querystat';";
    mysql_query($insertquery, $db);
    }

maybe something with == 0 ?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about insert