my queries are :
$select_userid_query = execute_pdo_query("SELECT user_id FROM users WHERE username='" . $_COOKIE['username'] . "'");
if ($select_userid_query == 0){
execute_pdo_query("INSERT INTO user_status
(user_id,last_activity_time) VALUES
((SELECT user_id FROM users WHERE username='" . $_COOKIE['username'] . "'),NOW())"
, array($user_id, $last_activity_time));
}
else{
execute_pdo_query("UPDATE user_status SET user_id = (SELECT user_id FROM users WHERE username='" . $_COOKIE['username'] . "'),last_activity_time= NOW()", array($user_id, $last_activity_time));
}
i want to verify if there is a record in the database and if not insert and if there’s just update the time of that with the new NOW()
any ideas where’s my error in the syntax?
Instead of this you can use this single query if you have a
user_idas unique: