我正在尝试检查行是否存在。我正进入(状态
Commands out of sync; you can't run this command
我收到此错误是因为我添加了$stmt->store_result();
如果我删除该行num_rows
不会返回 true。如何检查该行是否存在?
$title = urldecode($_GET['product-tit/']);
$id = $_GET['item-id-pr'];
$mydb = new mysqli('localhost', 'root', '', 'database');
if(empty($title) || empty($_GET['item-id-pr'])){
header('Location: products.php');
exit();
}
else{
$stmt = $mydb->prepare("SELECT * FROM products where title = ? AND id = ? limit 1 ");
$stmt->bind_param('ss', $title, $id);
$stmt->execute();
$stmt->store_result();
?>
<div>
<?php
if($stmt->num_rows < 1 ) {
echo "not found";
exit();
} else{
$result = $stmt->get_result();
echo $mydb->error;
while ($row = $result->fetch_assoc()) {
echo wordwrap($row['price'], 15, "<br />\n", true);
exit();
}
$mydb->close ();}}
?>
</div>