title: How to get affected rows using mysqli?
body: <p>I create function for make query in database:</p>
  
  <pre><code>function mysqli($query){
      $mysqli = new mysqli('test','test','test','test');
      if (mysqli_connect_errno()) {
          printf("Bad connect: %s\n", mysqli_connect_error());
          exit();
      }
      $result = $mysqli-&gt;query("SET NAMES utf8");
      $result = $mysqli-&gt;query("set character_set_client='utf8'");
      $result = $mysqli-&gt;query("set collation_connection='utf8_general_ci'");
      $result = $mysqli-&gt;query($query);
  
      $mysqli-&gt;close();
      return $result;
  };
  </code></pre>
  
  <p>In next step I want get count affected rows.</p>
  
  <p>For this I make:</p>
  
  <pre><code>$res2 = mysqli("INSERT INTO Table (name, value) VALUES ('$name', '$value')");
  echo $res2-&gt;affected_rows;
  </code></pre>
  
  <p>But I get <code>Notice: Trying to get property of non-object</code> on line <code>echo $res2-&gt;affected_rows;</code></p>
  
  <p>How to get count of <code>affected_rows</code>?</p>