这是ionic 3移动应用程序的php API。相同的逻辑在php mysql应用程序中工作正常,现在问题出在此...控制语句中的所有命令都在执行...根据条件,只应执行一个。 插入的mysqli_query返回false,即使在相反条件下mysqli_num_rows也返回1
请为此提出一个解决方案。努力寻求解决方案,但无法清除错误。直到现在我发表关于mysqli语句的观察结果
if ($proforma_invoice_no == '' || $proforma_dateTime == '' || $userdetails_name == '' || $userdetails_contact == '' || $userdetails_email == '' || $supervisor_name == '' || $supervisor_dep == '' || $equipment_incharge_name == '' || $equipment_incharge_email == '' || $equipment_incharge_contact == '' || $tests == '' || $sample_info == '') {
$response = "This QR doesnot belong here";
} // if empty
else {
$query = mysqli_query($conn, "SELECT * FROM qrcode_data WHERE proforma_invoice_no = $proforma_invoice_no");
$d = mysqli_fetch_array($query);
$t = mysqli_num_rows($query); //returning 1 even though there is no matching data
if (mysqli_num_rows($query) > 1 || mysqli_num_rows($query) == 1) {
$response = "Duplicate data";
} else {
$insert_query = mysqli_query($conn, "INSERT INTO qrcode_data(proforma_invoice_no,proforma_datetime,project_code,userdetails_name,userdetails_contact,userdetails_email,supervisor_name,supervisor_dep,equipment_incharge_name,equipment_incharge_email,equipment_incharge_contact,tests,sample_info,scanned_by,scanned_time) VALUES($proforma_invoice_no,'$proforma_dateTime','$project_code','$userdetails_name','$userdetails_contact','$userdetails_email','$supervisor_name','$supervisor_dep','$equipment_incharge_name','$equipment_incharge_email','$equipment_incharge_contact','$tests','$sample_info','$scanned_by',now())");
if ($insert_query) { // this is false every time and data is getting inserted also
$response = "New data";
} // if insert query
else {
$response = "No data posted";
} // else no insert query
} //else mysqli_nums_rows
} // else not nill
echo json_encode($response);