If the row for a specific user relevant to a specific product in the table called "user_star_rate" is null, I want to insert the data to the table and otherwise I want to update the table. But the update function is not working.
$jsqla7 = mysql_query("select * from user_star_rate where product_id='$product_id' and email='$visit_email'") or die(mysql_error());
$jfeta7 = mysql_fetch_assoc($jsqla7);
if($jfeta7 != null) {
$rate = "UPDATE user_star_rate SET rate_value='$rate_value' WHERE product_id='$product_id' and email='$visit_email'" ;
} else {
$rate = "INSERT INTO user_star_rate (email, product_id, rate_value) VALUES ('$visit_email','$product_id','$rate_value')" ;
}
REPLACE INTOmysql_num_rows($result) != 0instead of$jfeta7 != null