我面臨的一些問題是:警告:mysqli_fetch_array()預計參數1被mysqli_result,在C空給出: XAMPP htdocs中 ...在線路44
說明:未定義變量:信息搜索結果用C :...在線44
警告:mysqli_fetch_array()預計參數1被mysqli_result,在C空給出:...在線44
我不知道如何解決它,任何幫助將不勝感激。由於
generatereport.php
<?php
if(isset($_POST['search']))
{
$courseid = $_POST['courseid'];
$query = "SELECT * FROM course_registration WHERE r_cid ='$courseid'";
$searchResult = filterTable($query);
}
function filterTable($query)
{
include("include/config.php");
$filter_Result = mysqli_query($link, $query);
return $filter_Result;
}
?>
<fieldset style="font-family: 'Exo', sans-serif;">
<legend>Generate Report</legend>
<form name="GenForm" method="post" action="generatereport.php" onSubmit="return InputCheck(this)">
<table>
<tr>
<td>Course ID:</td>
<td><input id="courseid" name="courseid" type="text" class="input" pattern="([A-Z]{3,4})-[A-Z0-9]{3,5}"
title="Please enter a valid course id">
<span>(eg. DPT-3054)</span></td>
</tr>
</table>
<div>
<input type="submit" name="search" value=" Search By Course ID ">
</div>
<table width="70%" cellpadding="5" cellspacing="5">
<tr>
<th><strong>Course ID</strong></th>
<th><strong>Full Name</strong></th>
<th><strong>Student ID</strong></th>
<th><strong>Program</strong></th>
<th><strong>Intake</strong></th>
</tr>
<?php while ($row = mysqli_fetch_array($searchResult)) :?> **//line 44
<tr>
<td><?php echo $row['r_cid']; ?></td>
<td><?php echo $row['r_name']; ?></td>
<td><?php echo $row['r_sid']; ?></td>
<td><?php echo $row['r_program']; ?></td>
<td><?php echo $row['r_fintake']; ?></td>
</tr>
<?php endwhile; ?>
</table>
</form>
</fieldset>
<script language=JavaScript>
function InputCheck(GenForm)
{
if (GenForm.courseid.value == "")
{
alert("The field Course ID cannot be left blank!");
GenForm.courseid.focus();
return (false);
}
}
</script>
的config.php
<?php
$link= mysqli_connect("localhost","root","","course_registration_system");
?>
您需要檢查while循環之前的isset。 –
您的進程不是注入安全的,並且您在檢索行之前沒有檢查結果是否爲真/假。您沒有顯示任何調試/錯誤檢查,研究或自我解決的努力。 SO已經爲幾乎所有的事情做出了答案通過在你發佈之前不搜索,你會浪費你的時間和我們的(因爲現在你的重複問題必須審覈)。 Downvoted。 – mickmackusa