Using prepared statements would be a good first step.
$stmt = PDO::prepare("select * from user_favorites1 where users_id=:USER_PHONE AND products_id=:PRODUCT_ID LIMIT 0,1");
$stmt->bindValue(':USER_PHONE', $user_phone);
$stmt->bindValue(':PRODUCT_ID', $products_id);
$stmt->execute();
$result = $stmt->fetchAll();
Failing that, lots and lots of input sanitization.