'ok', 'err' => ''); try { if (empty($_POST) || empty($_POST["fno"])) throw new \Exception("parameter empty"); foreach ($_POST as $k => $v) { $$k = htmlspecialchars(stripslashes(trim($v))); } if (!$fno) throw new \Exception("parameter empty[2]"); switch ($fno) { case (preg_match('/TX/', $fno) ? true : false): $kind = "MAE100"; break; case (preg_match('/TW/', $fno) ? true : false): $kind = "MAM200"; break; case (preg_match('/TJ/', $fno) ? true : false): $kind = "MAH100"; break; case (preg_match('/TZ/', $fno) ? true : false): $kind = "MAZ100"; break; default: $kind = ""; } require_once "database.php"; $db_query = "select c.company, f.repairerid from contract c, facility f where c.contractno = f.contractno and f.facilityno = '$fno'"; $res = mysqli_query($link, $db_query); if ($row = mysqli_fetch_row($res)) { $rarr["addr"] = $row[0]; $rarr["rid"] = $row[1]; $rarr["kind"] = $kind; mysqli_free_result($res); } else { $rarr["addr"] = $rarr["rid"] = ""; } }catch(\Exception $e) { $rarr['st'] = 'err'; $rarr['err'] = $e->getMessage(); } echo json_encode($rarr, JSON_UNESCAPED_UNICODE); ?>