Warning: mysqli_num_rows() in php Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in.
This is my php code
$query = "SELECT * FROM `posts`";
$result = mysqli_query($conn,$query);
if(mysqli_num_rows($result) != 0):
anyone help me please.
i want to apply this in php
Well mysqli_query returns false on failure. So you are getting an error for some reason
From the official docs
Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.
error solve
$query = "SELECT * FROM `posts`";
$result = mysqli_query($conn,$query);
if (!$result){
die();
}
if(mysqli_num_rows($result) != 0):
how to resolve ? Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, array given in
if (mysqli_num_rows($result)) {
echo "
match_id
country
league
match_status
match_datetime
play_time
team1
team2
team1score
team2score
team1scoreHT
team2scoreHT
match_static_id
";
while($row = mysqli_fetch_array($result) <= 1) {
echo
"
edit
".$row['match_id']."
".$row['country']."
".$row['league']."
".$row['match_status']."
".$row['match_datetime']."
".$row['play_time']."
".$row['team1']."
".$row['team2']."
".$row['team1score']."
".$row['team2score']."
".$row['team1scoreHT']."
".$row['team2scoreHT']."
".$row['match_static_id']."
";
}
echo "
";
foreach($result as $good_id){
mysqli_free_result($good_id) <= 1;
}
} else{
echo "No records matching your query were found.";
}
mysqli_close($conn);
?>
Please sign in or create an account to participate in this conversation.