$q = intval($_GET['q']);
$con = mysqli_connect('localhost','root','','my_db');
if (mysqli_connect_errno()) {
echo "Fail to connect :".mysqli_connect_error();
}
mysqli_select_db($con,"my_db");
$sql="SELECT * FROM ajax WHERE id = '".$q."'";
$result = mysqli_query($con,$sql);
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row('Firstname') . "</td>";
echo "<td>" . $row('Lastname') . "</td>";
echo "<td>" . $row('AGE') . "</td>";
echo "<td>" . $row('Hometown') . "</td>";
echo "<td>" . $row('Job') . "</td>";
echo "</tr>";
echo "</table>";
}
mysqli_close($con);
我不斷收到這個錯誤:警告:mysqli_fetch_array()預計參數1被mysqli_result,布爾在C中給出:\ XAMPP \ htdocs中\ ABC \上線getuser.php 22mysqli_fetch_array不斷收到錯誤
如果對這個簡單的問題已經有了答案,我很抱歉,我是編碼方面的新手,我花了相當一段時間閱讀其他類似的問題,但仍然無法解決這個問題。 Thx提前。
可能重複[MySQL的\ _fetch \ _array()預計參數1是資源(或mysqli的\ _result),給定的boolean(http://stackoverflow.com/questions/2973202/mysql-fetch-array-expect-parameter-1-to-resource-or-mysqli-result-boole) – 2014-09-02 09:51:27
我認爲你的查詢沒有正確運行。數據庫中的id列數據類型是什麼? 所以$ result變量將始終初始化爲0 – Aksh 2014-09-02 09:53:49