I have one table called tbl_favorite. there two field called user_id and quote_id. I am passing this both field in parameter. I want check that user_id have any row with that quote_id. if its exist I want response like "already exist" else I want insert that data in table.
<?php
header('Content-Type: application/json; Charset=UTF-8');
include("dbconnection.php");
$userid= $_GET['userid'];
$quoteid= $_GET['quoteid'];
// I am confused to write condition
$query= mysqli_query($conn,"SELECT fav_id FROM tbl_fav WHERE user_id='".$userid.'" AND fav_qu_id="'.$quoteid.'"");
if(mysqli_num_rows($query) > 0){
$response="already exist";
}
else{
$query= mysqli_query($conn,"INSERT INTO tbl_fav(user_id,fav_qu_id VALUE('".$userid."','".$quoteid."')");
$response['message']='success';
}
echo json_encode($response);
?>
my url is like below
example.com/api.php?user_id=1&"e_id=1
I am getting error called Parse error: syntax error, unexpected '"'. Let me know if someone correct me. I am android developer and does not know proper PHP. Thanks