title: mysqli_insert_id Not Working
body: <p>I am trying to get last autoincrement id from INSERT/UPDATE query, i am trying this way, but its not working, it just echo <code>id=0</code> every time.</p>
  
  <p>PHP</p>
  
  <pre><code>require_once('conn.php'); 
  $temp = 'temp';
  
  $query = "INSERT INTO temp (temp) VALUES('$temp')";
  $result = mysqli_query($conn, $query) or trigger_error(mysqli_error($conn), E_USER_ERROR);
  
  $id = mysqli_insert_id($conn);
  echo 'id = '.$id;
  </code></pre>
  
  <p>Please see and suggest any possible way to do this.</p>