所以我无法弄清楚问题出在哪里,就好像我只绑定其中一个参数一样,它可以工作。如果两者都存在那么它给了我警告:mysqli_stmt::bind_param():变量数量与准备好的语句中的参数数量不匹配,并且不产生任何输出。似乎无法识别where子句中的第二个参数。如果有人能帮我解决这个问题,谢谢!如果我替换 ? 则查询有效 并在 phpMyAdmin 中运行。CNIC 应该是一个后值,并且为了测试目的而被硬编码。$sql = "SELECT c.cnic, c.name, c.cell_phone, c.address FROM cheetay_customers as c INNER JOIN policies as p ON c.CNIC = p.cnic WHERE `c`.`CNIC`= ? AND `p`.`partnerName`= ?";if($stmt = $con->prepare($sql)) { $cnic = 1267890; $stmt->bind_param("i", $cnic); $stmt->bind_param("s", $_SESSION['access']); $stmt->execute(); $stmt->bind_result($cnic, $name,$cell_phone,$address); while ($stmt->fetch()) { echo "CNIC: {$cnic}, Name: {$name}, Cell Phone: {$cell_phone}, Address: {$address}"; }} else { $error = $con->errno . ' ' . $con->error; echo $error; }
1 回答
噜噜哒
TA贡献1784条经验 获得超7个赞
调用bind_param
一次,一次性传递所有参数
$stmt->bind_param("is", $cnic, $_SESSION['access']);
- 1 回答
- 0 关注
- 110 浏览
添加回答
举报
0/150
提交
取消