我知道这个问题看起来像是重复的,但我真的读了很多,但并没有解决问题。
我想回显sql中的最后10行,我收到此错误。
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\rock\fyp\postAdv.php on line 10
THE Event:
THE Date:
THE Time:
THE Venue:
Note:
php文件是
<?php
$con=mysqli_connect("rock","mido","1234","fyp");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$start = 10;
$result = mysqli_query($con,"SELECT * FROM event ORDER BY ID DESC LIMIT $start,10");
$row = mysqli_fetch_array($result) ;
{
echo "<br><h4> " . "THE Event: " . $row['EventName'] . "</br>";
echo "<h4>" . "THE DATE: " . $row['Date'] ;
echo "<h4>" . "THE TIME: " . $row['Time'] ;
echo "<h4>" . "THE Venue: " . $row['Venue'] ;
echo "<h4>" . "Note: " . $row['Note'] ;
}
mysqli_close($con);
?>
答案 0 :(得分:3)
$result
是一个布尔值,因为您正在执行的查询失败!失败的查询会发出布尔值'false'
。
检查您的查询。在查询中使用之前,请尝试使用值设置$ start。
答案 1 :(得分:0)
在您的查询重试之前设置$ start = 1。
$start = 1;