2017-04-24 42 views
0

警告:mysqli_query()預計參數1是mysqli的,給定的字符串在 C:\ XAMPP \ htdocs中\ tutoringEnrollmentList.php第45行上具有這2個錯誤試圖在PHP顯示MySQL數據

警告:mysqli_fetch_array()預計參數1被mysqli_result, 空在C中給出:\ XAMPP \ htdocs中\ tutoringEnrollmentList.php線60上

這裏是線41-78

<?php 
$dbc = mysqli_connect ('localhost', 'root', '', 'studentDB') 
    or die (mysqli_connect_error()); 
$sql = "SELECT * FROM `tutoringservice`"; 
$data = mysqli_query($sql, $dbc); 

echo "<table border=1> 
<tr> 
<td> # </td> 
<td> Date </td> 
<td> Last Name </td> 
<td> First Name </td> 
<td> Email </td> 
<td> Student ID </td> 
<td> Subject </td> 
<td> Message </td> 
<td> Tutoring Day </td> 
</tr>"; 

while($record = mysqli_fetch_array($data)){ 
echo "<tr>"; 
echo "<td>" . $record['#'] . "</td>"; 
echo "<td>" . $record['Date'] . "</td>"; 
echo "<td>" . $record['Last Name'] . "</td>"; 
echo "<td>" . $record['First Name'] . "</td>"; 
echo "<td>" . $record['Email'] . "</td>"; 
echo "<td>" . $record['Student ID'] . "</td>"; 
echo "<td>" . $record['Subject'] . "</td>"; 
echo "<td>" . $record['Message'] . "</td>"; 
echo "<td>" . $record['Tutoring Day'] . "</td>"; 
echo "</tr>"; 
} 
echo "</table>"; 
mysqli_close($dbc); 



?> 

回答

3

您已經使用了不正確的順序在

$data = mysqli_query($sql, $dbc); 

應該是這樣

$data = mysqli_query($dbc, $sql); 
0

的答案是正確的@agam,但對你,我想建議,你應該檢查該具體查詢here。 和這樣的問題,你可以看here,我發現它在我的PHP和MySQL

0

嘗試的初期更加有用檢查此行導致的錯誤你

echo "<td>" . $record['#'] . "</td>";