title: mysqli insert_id not working
body: <p>Can someone take a look at this and tell me why it's not working. This is part of a class that I'm working on. The insert query works fine and if I call $char->db->insert_id; from outside the class it works ($char being the class)</p>
  
  <pre><code>function createChar($charName, $charRace, $charClass) {
      //put userId, charName and charRace into database
      $sql="insert into characters (userID, name, race, class) values ('$this-&gt;userID', '$charName', '$charRace', '$charClass') ";
      $result=$this-&gt;db-&gt;query($sql);
      if($this-&gt;db-&gt;affected_rows == '1')
          {
              return '1';
          }
          else
          {
              return '0';
          }
  
      //get last insert id     
      $this-&gt;charID=$this-&gt;db-&gt;insert_id;
  
  }
  </code></pre>