I have the following code:
$sql = 'INSERT INTO table VALUES ('', ...)'; $result = mysql_query($sql, $link) or die(mysql_error()); $id = mysql_insert_id($result) or die('oops'); //mysql_error() instead of oops produces the same result echo $id . '\nDone';
The table that this insert occurs on has an auto-incroment field however all that this outputs is:
Done
Am I doing something wrong?
You do not need to pass $result to mysql_insert_id you should pass $link variable.