為啥小弟我這個預先處理語句執行不了呢
來源:互聯網
上載者:User
為啥我這個預先處理語句執行不了呢
$mysqli= new mysqli("localhost","root","123456","xsphpdemo");
if(mysqli_connect_errno()){
echo "串連失敗
".mysqli_connect_error();
}
$stmt=$mysqli->prepare("select id name price num desn from shop where id>?");
$stmt->bind_param("i",$id);
$stmt->bind_result($id,$name,$price,$num,$desn);
$id="10";
$stmt->execute();
$stmt->store_result();
while($stmt->fetch()){
echo "$id -- $name -- $price -- $num -- $desn
";
}
echo $stmt->num_rows;
$stmt->close();
執行Var_dump("select id name price num desn from shop where id>?")
布爾型值是假
好像$mysqli->prepare()語句執行不成功,不知道為啥
------解決思路----------------------
"select `id`, `name`, `price`, `num` ,`desn` from shop where id>?"
------解決思路----------------------
欄位沒有隔開
$stmt=$mysqli->prepare("select id, name, price, num, desn from shop where id>?");