insert into friend_online (userid,onlineid,ipaddress,lastactive) values ('1','78671374046b8c68368b20','65.33.62.155',NOW())
Duplicate errors
I get this result on my site
Here is the code that does it
// process for online status
function update_online_status(){
$temp=$_SESSION['info'];
$LOCALIP=$_SERVER['REMOTE_ADDR'];
$lastactive = time();
// according to privacy setting
$online_hide1="3".",";
$online_hide2=","."3".",";
$online_hide3=","."3";
$online_hide4="3";
$privacy="select COUNT(*) as cnt from friend_acc_setting where user_id='$temp[auto_id]' AND (privacy like '$online_hide1%' or privacy like '%$online_hide2%' or privacy like '%$online_hide3' or privacy='$online_hide4')";
$result_privacy=executequery($privacy);
$row = mysql_fetch_array($result_privacy);
if($row['cnt'] == 0 ){
$sql_online="select * from friend_online where userid='$temp[auto_id]' and ipaddress='$LOCALIP'";
$result_online=executeQuery($sql_online);
if($line_online=mysql_fetch_array($result_online)){
$sql_update_online="update friend_online set lastactive=NOW() where userid='$temp[auto_id]' and ipaddress='$LOCALIP'";
executeQuery($sql_update_online);
} else {
if($temp[auto_id]!=''){
$unid=uniqid(rand());
$sql_insert_online="insert into friend_online (userid,onlineid,ipaddress,lastactive) values ('$temp[auto_id]','$unid','$LOCALIP',NOW())";
executeQuery($sql_insert_online);
}
}
}
$temp='';
$sql_delete="DELETE FROM friend_online WHERE lastactive <= DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
executeQuery($sql_delete);
}
The problem is it creates a new entry in my DB on everypage load, so then I change my DB to not allow duplicate entries then I receive errors on my site saying duplicate errors when trying to insert, I cant figure out whats going wrong