title: Best way to find the last inserted ID in mysql using php
body: <p>Im wondering as to what the best solution is to get the last inserted ID after a mysql inquiry?</p>
  
  <p>I have found the following solutions : </p>
  
  <pre><code>&lt;?php
  function get_current_insert_id($table)
  {
      $q = "SELECT LAST_INSERT_ID() FROM $table"; 
      return mysql_num_rows(mysql_query($q)) + 1;
  }
  ?&gt;
  </code></pre>
  
  <p>or even using <code>mysql_insert_id</code> php function, but apparently this function will not work well with bigint (thats what I am using for ID field) and if there are alot of consecutive sql inquiries it could be unreliable. </p>
  
  <p>Could someone provide a reliable and fast solution to achieve this task?</p>