""I made some PHP pages which control mysql database use it by android app i faced problem in the page which insert data to database when the user use app in bad network the record duplicated. So i increased an condition to check if that record is exist, before insert statement, the duplicate problem is solved but the page didn't send the response of success insert, which was working perfectly before adding the check of duplicate.
$check1 = mysqli_query($con,"SELECT * FROM ".$tablefault." WHERE username = '$username' AND shiftName = '$shiftname' AND machineNumber = '$machineNo' AND date = '$dat' AND time = '$time', fault = '$fault' AND action = '$action' AND fixed = '$fixed' AND equiptype = '$equiptype' ");
if ($check1->num_rows == 0) {
$sql1="INSERT INTO ". $tablefault ." (userName, shiftName, machineNumber, date, time, fault, action, fixed, equiptype) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
$statement = $con->prepare($sql1);
$statement->bind_param('sssssssss', $username, $shiftname, $machineNo, $dat, $time, $fault, $action, $fixed, $equiptype);
$statement->execute();
$statement->close();
}
$con->close();
$response["success"] = true;
echo json_encode($response);