title: MYSQL Error : Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given
body: <p>Is there anything wrong with my sql query? I always get this error </p>
  
  <blockquote>
    <p>Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given </p>
  </blockquote>
  
  <pre><code>&lt;?php
  include("connection.php");
  $mysqli-&gt;query("SET NAMES 'utf8'");
  $filter = "All";
  
  if ($filter == "All"){
      $sql="SELECT * FROM city ";
  }else if($filter == "Alphabetically"){
      $sql="SELECT * FROM city order by cityName ASC";
  }else if ($filter == "Region"){
      $sql="SELECT * FROM city order by region";
  }else{
      echo "Error sql";
  }
  $result=$mysqli-&gt;query($sql);
  while($e=mysqli_fetch_assoc($result)){
      $output[]=$e; 
  }
  
  print(json_encode($output)); 
  $mysqli-&gt;close();
  </code></pre>