当前位置: 代码迷 >> PHP >> 为啥小弟我这个预处理语句执行不了呢
  详细解决方案

为啥小弟我这个预处理语句执行不了呢

热度:37   发布时间:2016-04-28 17:40:03.0
为啥我这个预处理语句执行不了呢
<?php
$mysqli= new mysqli("localhost","root","123456","xsphpdemo");
if(mysqli_connect_errno()){
echo "连接失败<br>".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 <br>";
}
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>?");
  相关解决方案