 <p>You are using <code>PDO</code> to interface with the database. Use <a href="http://php.net/PDO.lastInsertId"><code>PDO::lastInsertId()</code></a> to get the last inserted id.</p> <pre><code>$stmt-&gt;execute(); echo 'last id was ' . $db-&gt;lastInsertId(); </code></pre> <p><code>mysql_insert_id()</code> is part of the <code>ext/mysql</code> extension. You cannot mix-match functions from both extensions to interface with the same connection.</p>