title: Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\ajax-complete\live-table-post.php on line 23
body: <p>When i am trying to fetch data from database showing warning error </p>
  
  <blockquote>
    <p>Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\ajax-complete\live-table-post.php on line 23</p>
  </blockquote>
  
  <p>I am trying to fetch data from database it is showing that error i am also used musqli_affedted_rows instead of mysqli_num_rows but its showing same error</p>
  
  <pre><code>&lt;?php
      $host     = "localhost"; $username = "root"; $password = "";$db_name  = "ajax_complete";
      $conn = mysqli_connect( $host, $username, $password, $db_name ) or die("cannot connect");
      $output = '';
      $sql    = "SELECT * FROM tbl_live-crud ORDER BY id DESC";
      $result  = mysqli_query($conn,$sql);
      $output.= '
          &lt;div class="table-responsive"&gt;
              &lt;table class="table table-bordered"&gt;
                  &lt;tr&gt;
                      &lt;td width="10%;"&gt;&lt;/td&gt;
                      &lt;td width="20%;"&gt;&lt;/td&gt;
                      &lt;td width="20%;"&gt;&lt;/td&gt;
                      &lt;td width="20%;"&gt;&lt;/td&gt;
                      &lt;td width="10%;"&gt;&lt;/td&gt;
                  &lt;/tr&gt;';
                  if(mysqli_num_rows($result) &gt; 0){
                      while($row = mysqli_fetch_array($result)){
                          $output .= '
                              &lt;td&gt;'.$row['id'].'&lt;/td&gt;
                              &lt;td class="fname" data-id1="'.$row['id'].'" contenteditable&gt;'.$row['fname'].'&lt;/td&gt;
                              &lt;td class="lname" data-id2="'.$row['id'].'" contenteditable&gt;'.$row['lname'].'&lt;/td&gt;
                              &lt;td class="email" data-id3="'.$row['id'].'" contenteditable&gt;'.$row['email'].'&lt;/td&gt;
                              &lt;td&gt;&lt;button name="delete" id="delete" data-id4="'.$row['id'].'"&gt;X&lt;/button&gt;&lt;/td&gt;';
                              }
  
                          $output = '
                              &lt;tr&gt;
                                  &lt;td id="fname" contenteditable&gt;&lt;/td&gt; 
                                  &lt;td id="lname" contenteditable&gt;&lt;/td&gt; 
                                  &lt;td id="email" contenteditable&gt;&lt;/td&gt; 
                                  &lt;td id="btn_add" name="btn_add" class="btn btn-xs btn-success"&gt;&lt;button&gt;+&lt;/button&gt;&lt;/td&gt; 
                              &lt;/tr&gt;';
                  }else{
                      $output = '
                          &lt;tr&gt;
                              &lt;td colaspan="4"&gt; Data not Found&lt;/td&gt;
                          &lt;/tr&gt;';
                  }
                  $output .='&lt;/table&gt;
                  &lt;/div&gt;';
  
  ?&gt;
  </code></pre>