How do i fix mysqli_expects parameter 1 to be mysqli_result string given

When i try to execute the query and get the number of rows then and error is generated. I have been trying to fix this issue for days and i am new to php so it probably might not even be a syntax problem.

  <?php   // error_reporting(0);    $flying_from = "";   $flying_to = "";   $departure_date = "";   $return_date = "";   $number_of_adults = "";   $number_of_children = "";   $flight_class = "";    // Connect to database   $conn = mysqli_connect('localhost', 'presh', '1234', 'saffron');    if (isset($_GET['submit'])) {     $flying_from = $_GET['flying_from'];     $flying_to = $_GET['flying_to'];     $departure_date = $_GET['departure_date'];     $return_date = $_GET['return_date'];     $number_of_adults = $_GET['number_of_adults'];     $number_of_children = $_GET['number_of_children'];     $flight_class = $_GET['flight_class'];      $query = "SELECT * FROM flights WHERE flying_from LIKE $flying_from AND flying_to LIKE $flying_to AND departure_date LIKE $departure_date AND return_date LIKE $return_date AND     number_of_adults LIKE $number_of_adults AND number_of_children LIKE $number_of_children AND flight_class LIKE $flight_class";     $result = mysqli_query($conn,$query);      $count = mysqli_num_rows($result);      if($count > 0){         $output = 'There was no search results';     }else{       while ($row = mysqli_fetch_array($query)) {         $fFrom = $row['flying_from'];         $fTo = $row['flying_to'];         $dDate = $row['departure_date'];         $rDate = $row['return_date'];         $nAdults = $row['number_of_adults'];         $nChildren = $row['number_of_children'];         $fClass = $row['flight_class'];          $output .= '<div>'.$fFrom.' '.$fTo. ' '.$dDate.' '.$rDate.' '.$nAdults.' '.$nChildren.' '.$fClass.'</div>';     }   } } ?> 
Add Comment
1 Answer(s)

You need to pass the $result variable not $query in mysqli_fetch_array()

while ($row = mysqli_fetch_array($result)) {  } 
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.