mysql_insert_id(); / last_insert_id();
isn't returning latest ID without any known issue
$insert = "INSERT into `table` (`name`,`address`) VALUES ('$name', '$address')"; mysql_select_db($database_A, $A);
$result = mysql_query($insert,$A) or die mysql_error();
$latest_id = mysql_insert_id($A);
var_dump($latest_id);
According to PHP
manual I see any reason in the code why it's not returning the latest ID
, instead it's always returning NULL
or 0
. It's happening in case of last_insert_id();
too.
This function returns 0 if the previous operation does not generate an AUTO_INCREMENT ID, or FALSE on MySQL connection failure.
Any idea?