Problem with conditional insert

0

I am trying to get a conditional insert so I do not duplicate entries in the table but you are not inserting anything to me

Code

<?php
session_start();
if(isset($_SESSION['user_id'])){
    mysql_query("INSERT INTO visitas_estabelecimento (user_id, estabelecimento_id) VALUES ('".$_SESSION['user_id']."', '".$row_cat->id."')
WHERE NOT EXISTS 
    (SELECT * FROM visitas_estabelecimento 
    WHERE estabelecimento_id='".$row_cat->id."' and user_id='".$_SESSION['user_id']."'");
}
?>
   $row_user_id=mysql_fetch_object($result_verifica);
    $_SESSION['user_id'] = $row_user_id->id;
    
asked by anonymous 20.02.2015 / 21:09

0 answers