title: mysql_insert_id() not returning a value -
body: <p>I need to retrieve the auto increment field from my database table. I tried the following but <code>$id</code> is always just empty.</p>
  
  <p>The insert works too.</p>
  
  <p>My table is as follows:
  <code></code>id<code>int(9) NOT NULL auto_increment,</code></p>
  
  <p>and <code>id</code> is set as primary</p>
  
  <p>What am I doing wrong?
          $conn = mysql_connect($host,$username,$password);
          mysql_select_db($database, $conn) or die( "Unable to select database");
          include "update_activity.php";
          updateActivity("logged in", "On Break");</p>
  
  <pre><code>    $date = date("m/d/y"); $starttime = time();
      $sesh = $_SESSION['fname']." ".$_SESSION['lname'];
      $q = "INSERT INTO `breaks` (date, starttime, user) VALUES ('".$date."', '".$starttime."', '".$sesh."')";
  
      $query = mysql_query($q, $conn);
      $id = mysql_insert_id($conn);
  
      echo var_dump($id); exit;
  </code></pre>
  
  <p>edited to show my more recent attempts</p>