title: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given
body: <p>When I click on search button without entering any text in textbox it gives me "Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, string given" this error, how can I sort out this issue,here is my code any help will be appreciated</p>
  
  <pre><code>&lt;?php
  $title ="Manage Page";
  include "includes/home_page_header.php";
  ?&gt;
  &lt;?php
  $error_array = array();
  $count =1;
  $firstName = $lastName = $email = $status =$res_users = $checkbox ="";
  
  if(isset($_POST['Search']))
  {
      $firstName = $_POST['firstName'];
      $lastName  = $_POST['lastName'];
      $email     = $_POST['email'];
      $status    = $_POST['status'];      
  
  
  if($firstName !="")
  {
      $sql_users ="SELECT * FROM `users` WHERE `firstName` LIKE '$firstName'";
  }
  else if($lastName !="")
  {   
      $sql_users ="SELECT * FROM `users` WHERE `lastName` LIKE '$lastName'";
  }
  else if($email !="")
  {   
      $sql_users ="SELECT * FROM `users` WHERE `email` LIKE '$email'";
  }
  else if($firstName !="" &amp;&amp; $lastName !="")
  {
      $sql_users ="SELECT * FROM `users` WHERE `firstName` LIKE '$firstName' AND `lastName` LIKE '$lastName'";
  }
  else
  {
      $sql_users = "SELECT * FROM `users`";
  }   
  
  if(isset($_GET['user_id']))
  {
      $user_id = $_GET['user_id'];
  
      $sql_users = "DELETE from `users` WHERE user_id=".$user_id;
  
  if ($link-&gt;query($sql_users) == TRUE)
  {
       $error ="Record deleted successfully"; 
       array_push($error_array,$error);
  }
  if ($link-&gt;query($sql_users) == FALSE) 
  {
      $error = "Your Abort Delete operation";
      array_push($error_array,$error);
  }
  }
  
  if($status == "Active")
  {
      $sql_users= "SELECT * FROM `users` WHERE `status` LIKE 'Active'";
      $res_users = mysqli_query($link,$sql_users);
  
      if($res_users &amp;&amp; mysqli_num_rows($res_users) &gt; 0)
      {           
          while($log_row_users = mysqli_fetch_assoc($res_users))                              
          {
             $status = $log_row_users["status"];                  
          }
      }
  }
  if($status == "Inactive")
  {
      $sql_users= "SELECT * FROM `users` WHERE `status` LIKE 'Inactive'"; 
      $res_users = mysqli_query($link,$sql_users);
  
      if($res_users &amp;&amp; mysqli_num_rows($res_users) &gt; 0)
      {           
          while($log_row_users = mysqli_fetch_assoc($res_users))                              
          {
             $status = $log_row_users["status"];          
          }
      }
  }
  $res_users = mysqli_query($link ,$sql_users);
  
  
  }
  if(isset($_POST['delete_all']))
  {
  
  }
  
  ?&gt;
  &lt;script&gt;
  $(document).ready(function()
  {
      $(".delete_button").on('click',function()
      {
          var result =confirm("Are you sure you want to delete ?");
          if(result)
          {
              return true;
          }
          else
          {
              return false;
          }
      });
  });
  //function wantTodelete(user_id)
  //{
  //  return confirm("Are you sure you want to delete ?");
  //}
  
  
  $(document).ready(function()
  {
      $("#checkAll").change(function () {
      $("input:checkbox").prop('checked', $(this).prop("checked"));
  });
  });
  
  &lt;/script&gt;
  &lt;table border="1px" class="manage_table"&gt;
  &lt;form name="listingForm" action="" method="post"&gt;
  &lt;tr&gt;
  &lt;?php
  if($error_array !=0)
  {
      foreach($error_array as $value)
      {
          echo "&lt;tr style='color:green;'&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt; ". $value. "&lt;/td&gt;&lt;/tr&gt;";   
      }
  }
  ?&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="firstName"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="lastName"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="email"&gt;&lt;/td&gt;
  &lt;td&gt;
  &lt;select name="status"&gt;
  &lt;option&gt;Select Status &lt;/option&gt;
  &lt;option value="Active"   &lt;?php echo $status;?&gt;&gt;Active     &lt;/option&gt;
  &lt;option value="Inactive" &lt;?php echo $status;?&gt;&gt;Inactive   &lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;td&gt;&lt;input style="width:135px" type="submit" name="Search" value="Search"&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" id="delete_all" name="delete_all" value="Delete All" onclick="return deleteAll();" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th&gt;Sr.No&lt;/th&gt;
  &lt;th&gt;First Name&lt;/th&gt;
  &lt;th&gt;Last Name&lt;/th&gt;
  &lt;th&gt;Email&lt;/th&gt;
  &lt;th&gt;Status&lt;/th&gt;
  &lt;th&gt;Action&lt;/th&gt;
  &lt;th&gt;&lt;input type="checkbox" id="checkAll" name="check_all[]"/&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;?php                       
  if($log_row_users = mysqli_fetch_assoc($res_users))                             
  {            
       $user_id      = $log_row_users['user_id'];  
       $firstName    = $log_row_users['firstName'];
       $lastName     = $log_row_users['lastName'];
       $email        = $log_row_users['email'];
       $status       = $log_row_users['status'];
  
  ?&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;?php echo $count++  ;?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $firstName;?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $lastName ;?&gt;&lt;/td&gt;
  &lt;td&gt;&lt;?php echo $email    ;?&gt;&lt;/td&gt;
  &lt;td&gt;
  &lt;?php 
  if($status == "Active")
  {
      echo "&lt;b style='color:#3CF'&gt;".$status."&lt;/b&gt;";
  }
   if($status == "Inactive")
  {
      echo "&lt;b style='color:#F00'&gt;".$status."&lt;/b&gt;";
  };
  ?&gt;
  &lt;/td&gt;
  &lt;td&gt;
  &lt;a style="margin-left:25px" href="http://localhost/sample/home_page_edit.php?user_id=&lt;?php echo $user_id;?&gt;" onclick="redirectMe();" name="redirect" id="redirect"&gt;&lt;img src="images/pencil.png" /&gt;&lt;/a&gt;
  
  
  &lt;a style="margin-left:35px"  href="http://localhost/sample/home_page_manage.php?user_id=&lt;?php echo $user_id;?&gt;" name="delete_button" class="delete_button" &gt;&lt;img src="images/delete.png" /&gt;&lt;/a&gt;
  &lt;/td&gt;
  &lt;th&gt;
  &lt;input name="checkbox[]" type="checkbox" id="checkbox[]" class="checkbox"&gt;
  &lt;/th&gt;
  &lt;/tr&gt;
  &lt;/form&gt;
  &lt;?php
  }
  ?&gt;
  &lt;/table&gt;
  &lt;?php
  include "includes/home_page_footer.php";
  ?&gt;
  </code></pre>