我已經修改了我的代碼,並希望這是多一點就應該是這樣,謝謝大家的幫助,這是非常讚賞SQLI準備好的聲明
<?php
$mysqli = new mysqli("localhost", "root", "", "project");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if ($stmt = $mysqli->prepare("SELECT * FROM users WHERE ? BETWEEN ? AND ?")){
$stmt->bind_param('iii',$weight, $weight1 ,$weight2);
$weight = "weight";
$weight1 = "weight + 1";
$weight2 = "weight - 1";
$stmt->execute();
echo "{$weight}";
echo "{$weight1}";
echo "{$weight2}";
$stmt->close();
}
else {
printf("Prepared Statement Error: %s\n", $mysqli->error);
}
?>
您正在使用2'?'在您的準備聲明中。這意味着你必須在'bind_param()'中使用兩個變量' – Tabby
注意:這行if($ stmt = $ mysqli-> prepare(「SELECT ....'缺少關閉')' –
@弗雷德的筆記,請只在這裏提供代碼,你已經嘗試過 - 如果它會導致一個解析錯誤,需要先修復':)'。 – halfer