Php 从数据库中筛选铁路超高
我有一个问题,当我搜索一个单词时,它不会出现,这个错误会弹出 警告:mysqli_fetch_array()希望参数1是mysqli_结果,布尔值在第213行的C:\xampp\htdocs\public_html\filterdata.php中给出 它只显示筛选前的表Php 从数据库中筛选铁路超高,php,filter,Php,Filter,我有一个问题,当我搜索一个单词时,它不会出现,这个错误会弹出 警告:mysqli_fetch_array()希望参数1是mysqli_结果,布尔值在第213行的C:\xampp\htdocs\public_html\filterdata.php中给出 它只显示筛选前的表 <?php include("auth_admin.php"); if(isset($_POST['search'])) { $valueToSearch = $_POST['valueToSearch']; // s
<?php
include("auth_admin.php");
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM `lcho_dengue_activities` CONCAT(`id`, `month`, `year`, `dengue_ind1`) where `month`= '".$valueToSearch."'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `lcho_dengue_activities`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "", "lcho_login");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>
<form action="filterdata.php" method="post">
<input type="text" name="valueToSearch" placeholder="Value To Search"><br><br>
<input type="submit" name="search" value="Filter"><br><br>
<table>
<tr>
<th>Id</th>
<th>Month</th>
<th>Year</th>
<th>dengue_ind1</th>
</tr>
<!-- populate table from mysql database -->
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['month'];?></td>
<td><?php echo $row['year'];?></td>
<td><?php echo $row['dengue_ind1'];?></td>
</tr>
<?php endwhile;?>
</table>
</form>
//而($row=mysqli\u fetch\u array($search\u result))
是我的第213行
我尝试将
$search\u result
更改为$query
,同样的错误也发生了。该查询失败并返回false
把这个放在mysqli\u query()
后面,看看发生了什么
if (!$filter_Result) {
printf("Error: %s\n", mysqli_error($connect));
exit();
}
有关更多信息:
错误:您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以了解可在“(
id
,month
,year
,dengue\u ind1
)附近使用的正确语法其中,month
='january''在第1行警告:您完全可以使用参数化的准备语句,而不是手动生成查询。它们由或提供。永远不要相信任何类型的输入,尤其是来自客户端的输入。即使您的查询仅由受信任的用户执行。