致命错误:未捕获错误:调用未定义函数mysqli_stmt_get_result() [英] Fatal error: Uncaught Error: Call to undefined function mysqli_stmt_get_result()
本文介绍了致命错误:未捕获错误:调用未定义函数mysqli_stmt_get_result()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个致命错误,并且到处都有很多解决方案,但是我似乎找不到适合我代码的正确解决方案...
I'm dealing with a fatal error, and I see a lot of solutions for it everywhere but I can't seem to find the right solution that fits in my code...
所以这是出错的代码:
$link = mysqli_connect($server, $gebruiker, $wachtwoord, $database);
if($link === false) {
die("ERROR: Kon geen verbinding maken. " . mysqli_connect_error());
}
if(isset($_REQUEST['term'])) {
$sql = "SELECT * FROM producten WHERE naam LIKE ?";
if($stmt = mysqli_prepare($link, $sql)) {
mysqli_stmt_bind_param($stmt, "s", $param_term);
$param_term = '%' . $_REQUEST['term'] . '%';
if(mysqli_stmt_execute($stmt)) {
$result = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<p><a href=toevoegen.php?id=" . $row['id'] . " style=\"text-decoration: none\">" . $row["naam"] . "</a></p>";
}
} else {
echo "<p>Geen producten gevonden</p>";
}
} else {
echo "ERROR: Kon $sql niet uitvoeren. " . mysqli_error($link);
}
}
mysqli_stmt_close($stmt);
}
mysqli_close($link);
这是使一切混乱的部分:
this is the part that messes it all up:
$result = mysqli_stmt_get_result($stmt);
谁能在正确的方向帮助我,谢谢!
Who can help me in the right direction, thanks!
推荐答案
我修复了该问题,解决方案:
I fixed it, the solution:
if(isset($_REQUEST['term'])) {
$conn = mysqli_connect($server, $gebruiker, $wachtwoord, $database); //Connection to my database
$query = "SELECT id, naam FROM producten WHERE naam LIKE ?";
$statement = $conn->prepare($query);
$term = "%".$_REQUEST['term']."%";
$statement->bind_param("s", $term);
$statement->execute();
$statement->store_result();
if($statement->num_rows() == 0) {
echo "<p>Geen producten gevonden ".$_REQUEST['term']."</p>";
$statement->close();
$conn->close();
} else {
$statement->bind_result($id,$naam);
while ($statement->fetch()) {
echo "<p><a href=toevoegen.php?id=" . $id ." style=\"text-decoration: none\">" . $naam . "</a></p>";
};
$statement->close();
$conn->close();
};};
这篇关于致命错误:未捕获错误:调用未定义函数mysqli_stmt_get_result()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文