我有一个PHP
错误,我似乎无法修复此代码
$_POST['location'] = 'Northern Province';
$_POST['transport'] = 'transport';
if (isset($_POST['location'])) {
$region = "%{$_POST['region']}%";
$transport = "%{$_POST['transport']}%";
$stmt = $conn->prepare("SELECT users.id, users.email, users.profilePhoto, users.userType, organization.userFk, organization.name, organization.specialization from users, organization WHERE users.id = organization.userFk AND organization.specialization LIKE ? AND users.region LIKE ?");
$stmt->bind_param("ss", $transport, $regions);
$stmt->execute();
$response["transPortCompanies"] = array();
$stmt->bind_result($id, $email, $profilePhoto, $userType, $userFk, $name, $specialization);
while($row = $stmt->fetch()) {
$company = array();
$company["id"] = $id;
$company["email"] = $email;
$company["profilePhoto"] = $profilePhoto;
$company["name"] = $name;
$company["specialization"] = $specialization;
$response["message"] = "Loaded";
$response["error"] = FALSE;
array_push($response["transPortCompanies"], $company);
}
echo json_encode($response);
显然它会返回一个空的companies
列表,但是当我像
SELECT users.id, users.email, users.profilePhoto, users.userType, organization.userFk, organization.name, organization.specialization from users, organization WHERE users.id = organization.userFk AND organization.specialization LIKE '%transport%' AND users.region LIKE '%Northern Province%'
我得到了我的输出,所以我想知道我哪里出错了?我有另一个搜索的脚本,这就是我实现它的方式
答案 0 :(得分:2)
我猜你有拼写错误
bind_param("ss", $transport, $region); // "region", not "regionS"