所以我無(wú)法弄清楚問(wèn)題出在哪里,就好像我只綁定其中一個(gè)參數(shù)一樣,它可以工作。如果兩者都存在那么它給了我警告:mysqli_stmt::bind_param():變量數(shù)量與準(zhǔn)備好的語(yǔ)句中的參數(shù)數(shù)量不匹配,并且不產(chǎn)生任何輸出。似乎無(wú)法識(shí)別where子句中的第二個(gè)參數(shù)。如果有人能幫我解決這個(gè)問(wèn)題,謝謝!如果我替換 ? 則查詢(xún)有效 并在 phpMyAdmin 中運(yùn)行。CNIC 應(yīng)該是一個(gè)后值,并且為了測(cè)試目的而被硬編碼。$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貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超7個(gè)贊
調(diào)用bind_param
一次,一次性傳遞所有參數(shù)
$stmt->bind_param("is", $cnic, $_SESSION['access']);
- 1 回答
- 0 關(guān)注
- 176 瀏覽
添加回答
舉報(bào)
0/150
提交
取消