Call to a member function mysql_affected_rows() on a non-object
<p>I've got an error saying </p>

<blockquote>
  <p>Call to a member function mysql_affected_rows() on a non-object in C:\xampp\htdocs\initializr\search.php on line 189</p>
</blockquote>

<p>when I click my submit button.</p>

<pre><code>if(isset($_POST['select'])) {
    $studId = $_REQUEST['studid'];

    foreach ($studId as $ch) {
        $result = $mysqli-&gt;query("INSERT INTO tbl_tempCand (datetime, names) VALUES (CURRENT_TIMESTAMP(), '".$ch."')");
        //this is my line 189 error
        if($row-&gt;mysql_affected_rows($result)==0) {
            header("Location: registercand.php");
        } else {
            echo "nothing happen";
        }
    }
}
</code></pre>

<p>Why is that?</p>
