Click here to Skip to main content
15,917,940 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php
//Have done the connections to the db here but have left it out
//flights
$sql = "SELECT f.Flight_no, fi.DepartureDate..(there are too many rows to add so left this out here)
$result = mysqli_query($link,$sql);

if (mysqli_num_rows($result)>0) #5

{
if(strcmp($_GET['optradio'],"oneway")==0) ----- problem
{
echo("

Flights

");
}

What I have tried:

I have already done the database connection before this code and everything up until here works. The problem occurs on line 5. The error that shows when the code has been run is Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in home/.....
I've looked online and attempted many ways of fixing it but nothing is working. Any explanation of what could be wrong?
Posted
Updated 4-Mar-18 10:46am

1 solution

mysqli_query[^] returns FALSE if the query fails. You should test the return value before using it with any other mysqli calls. Use mysqli_error to print the error message if you get a FALSE result.
 
Share this answer
 
Comments
Member 13708337 4-Mar-18 17:23pm    
Thanks I’ve done that but it doesn’t show me the error message, it keeps pulling up that same line(5), not sure whether I should just redo the code to retrieve the data from the DB in another way

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900