I am retreiving the contents form an array and adding them in to the variables.(The variables are not empty, I have checked using echo). I am trying to return success in JSON if my contents are added into the database but im unable to do so.I am getting the result as false.
The $con is created correctly and is also working perfectly for a "select" query on this connection just before this part of code displayed below.I have added the $con statement below just for better understanding.
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database) or die(mysql_error());
$id=$record["id"];
$caller=$record["caller"];
$receiver=$record["receiver"];
$mapurl=$record["mapurl"];
$timestamp=$record["timestamp"];
$res=mysqli_query($con,"INSERT INTO call (id,caller,receiver,mapurl,timestamp) VALUES ('$id','$caller','$receiver','$mapurl','$timestamp')");
if ($res) {
$response["success"] = 1;
$response["message"] = "Added the Values in the Database";
echo json_encode($response);
}
else{
$response["success"] = 0;
$response["message"] = "Insert Not Successful";
echo json_encode($response);
}
My Output :
{"success":0,"message":"Insert Not Successful"}
My Database Structure :
(I am unable to post the image here as i have low reputation and one needs 10 reputation to do so)
MySQL
Table name: call
Columns - Datatypes
id - int(255)
caller - text
receiver - text
mapurl - text
timestamp - text