Entry
Has anyone else had any problems with getting mysql_insert_id ($result) return a value using mysql 3.23.21 with Win98 and PHP 4?
Dec 22nd, 2000 12:09
Ben Udall, Bobby Edge, http://www.php.net/manual/function.mysql-insert-id.php
From your question, it would appear that you're using the result from
the query as a parameter, like this:
$result = mysql_query($query);
$id = mysql_insert_id($result);
However, the php 3 and 4 documentation says mysql_insert_id() takes a
link identifier as an optional parameter, not a result identifier.
Below is an example of how it should be used.
$db_link = mysql_connect();
$result = mysql_query($query, $db_link);
$id = mysql_insert_id($db_link);
You can also omit the '$db_link' parameter, and php will use the last
database connection made, as shown below:
$result = mysql_query($query);
$id = mysql_insert_id();