我对 php 有点陌生,我正在尝试从数据库中检索原始数据,结果始终为空。我已经使用以下代码在表中插入了一条记录并且它有效。
INSERT INTO `registeration`.`cars` (`lnumber`, `type`, `model`, `motor`, `owner`
,`expdate`) VALUES ('123654', 'Nissan maxima', '2008',
'1500', 'name name', '2013-11-30');
结果是 1 个原始插入
php文件中使用的代码是:
if (isset($_GET["lnumber"])) {
$lnumber = $_GET['lnumber'];
echo $lnumber;
$result = mysql_query("SELECT * FROM cars WHERE lnumber = $lnumber");
if (!empty($result)) {
// check for empty result
if (mysql_num_rows($result) > 0) {
....code....
}
} else {
// no car found
$response["success"] = 0;
$response["message"] = "No cars found";
// echo no users JSON
echo json_encode($response);
}
} else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
但是,结果总是:123654{"success":0,"message":"No cars found"}