if ($_GET['id']) { $sq1 = mysql_query("SELECT COUNT(*) AS count FROM ads_hits WHERE hits = '".$_GET['id']." ".$_SERVER['REMOTE_ADDR']."'"); if (mysql_result($sql, 0, 'count') > 0) { $sql2 ="UPDATE ads_hits SET hits_count= hits_count +1 WHERE hits='".$_GET['id']." ".$_SERVER['REMOTE_ADDR']."' "; $updated=true; mysql_query($sql2); echo FINISHED; exit(); } else { $sql_2="insert into ads_hits(hits,hits_id,hits_ip,hits_count) values('".$_GET['id']." ".$_SERVER['REMOTE_ADDR']."','".$_GET['id']."','".$_SERVER['REMOTE_ADDR']."','0')"; $res=mysql_query($sql_2); echo ADDED; exit(); } } i have this code which inserts data into the database, but if the record is allready in the database it does not add 1 to the hits_count. can anyone help?