php 警告:mysqli_fetch_array() 期望参数 1 是 mysqli_result,布尔值在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22486793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:57:56  来源:igfitidea点击:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in

phpsqlmysqli

提问by opa.mido

I know this question looks like repeated, but I really read a lot but doesn't solve the problem.

我知道这个问题看起来像是重复了,但我确实阅读了很多但并没有解决问题。

I want to echo the last 10 rows in sql and I get this error.

我想回显 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:

the php file is

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);
?>

采纳答案by Caimen

Set $start = 1 before your query try again.

在您的查询重试之前设置 $start = 1。

$start = 1;

回答by arijeet

$resultis a boolean because the query you are executing is failing! A failed query gives off boolean 'false'.

$result是一个布尔值,因为您正在执行的查询失败了!失败的查询会发出 boolean 'false'

Check you query. Try setting $start with a value before using it in your query.

检查您的查询。尝试在查询中使用 $start 之前为其设置一个值。