gpt4 book ai didi

php - mysqli_stmt_execute() 期望参数 1 为 mysqli_stmt,

转载 作者:行者123 更新时间:2023-11-29 06:32:29 24 4
gpt4 key购买 nike

<分区>

您好,我需要一些帮助。我目前正在尝试创建一个搜索页面,用户可以在其中通过书名、类别、年份和出版商搜索特定书籍

我已经创建了我的基本 HTML 搜索表单,这是下面的代码:

<!DOCTYPE html>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Page Title</title>
</head>
<body>
<form id ="SearchPage" action="SearchPage.php" method="get">
<h1> Search Page</h1>

Book Title <input type="text" name="bookTitle" />

Category <select name="catDesc">
<option value = "Business & Commerce">Business & Commerce</option>
<option value = "Databases">Databases</option>
<option value = "Databases and Web Development">Databases and Web Development</option>
<option value = "Fiction">Fiction</option>
<option value = "Flex & Flash Programming">Flex & Flash Programming</option>
<option value = "Netorks">Netorks</option>
<option value = "Programming">Programming</option>
<option value = "Systems Design">Systems Design</option>
<option value = "Web Development">Web Development</option>
</select>



Publisher <input type="text" name="pubName"/>

Year <input type="text" name="bookYear"/>

<input type ="submit" value-"Find Books"/>

</form>
</body>
</html>

这是我在下面完成的 php 代码:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Search Page</title>
</head>
<body>
<table>
<tr>
<th>Book Title</th>
<th>Year</th>
<th>Category</th>
<th>Publisher</th>
</tr>
<?php

include 'database_mysqli_conn.php';

$bookTitle = $_REQUEST['bookTitle'];
$bookYear =$_REQUEST['bookYear'];
$catDesc =$_REQUEST['catDesc'];
$pubName =$_REQUEST['pubName'];

$sql = "SELECT bookTitle, bookYear, catDesc, pubName, FROM nbc_book b inner join nbc_category c on b.catID = c.catID inner join nbc_publisher p on b.pubID = p.pubID WHERE 1";

$stmt = mysqli_prepare($conn, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $bookTitle, $bookYear, $bookPrice, $catDesc);

if (!empty($bookTitle)) {

$sql= $sql." AND bookTitle = '$bookTitle'";

}

if (!empty($bookYear)) {

$sql= $sql." AND bookYear = '$bookYear'";

}

if (!empty($catDesc)) {

$sql= $sql." AND catDesc = '$catDesc'";

}

if (!empty($pubName)) {

$sql= $sql." AND pubName = '$pubName'";

}

while (mysqli_stmt_fetch($stmt)){
echo "<tr>
<td>$bookTitle</td>
<td>$bookYear</td>
<td>$catDesc</td>
<td>$pubName</td>
</tr>";
}

mysqli_stmt_close($stmt);
mysqli_close($conn);

?>

</body>
</html>

问题是,这是我提交搜索时收到的错误消息:

警告:mysqli_stmt_execute() 期望参数 1 为 mysqli_stmt,第 27 行/home/unn_w11036829/public_html/PHPexercises/SearchPage.php 中给出的 boolean 值

警告:mysqli_stmt_bind_result() 期望参数 1 为 mysqli_stmt, boolean 值在第 28 行的/home/unn_w11036829/public_html/PHPexercises/SearchPage.php 中给出

警告:mysqli_stmt_fetch() 期望参数 1 为 mysqli_stmt, boolean 值在/home/unn_w11036829/public_html/PHPexercises/SearchPage.php 第 54 行

警告:mysqli_stmt_close() 期望参数 1 为 mysqli_stmt,这是/home/unn_w11036829/public_html/PHPexercises/SearchPage.php 第 63 行中给出的 boolean 值书名年份类别出版商

谁能告诉我哪里错了!在过去的一个小时里,我一直坚持这个,它让我发疯。

提前谢谢你

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com