title: Using select last_insert_id() from php not working
body: <p>I have <a href="https://stackoverflow.com/questions/3425625/using-last-insert-id-via-php">this exact same issue</a>, but that answer is old, and I've read other places the use of mysql_insert_id() is depreciated and should be avoided in new code.</p>
  
  <p>The database is InnoDB and the primary key for this table is set to auto_increment.</p>
  
  <p>Can anyone see what I'm doing wrong here? I should note I'm a beginner and learning on my own, so I apologize is this is glaringly obvious.</p>
  
  <pre><code>$query  = "INSERT INTO VENUES (province,city,venue)" . "VALUES " . "('$province','$city','$venue')";
  $result = $db-&gt;query($query);
  if ($result) {
      echo "$result row(s) sucessfully inserted.&lt;br/&gt;";
  } else {
      echo "$db-&gt;error&lt;br/&gt;";
  }
  
  $result = $db-&gt;query("select last_insert_id()");
  echo $result-&gt;num_rows //returns 1
  echo $result; //nothing beyond this line happens
  </code></pre>
  
  <p>UPDATE: I am using mysqli.</p>