The ID of the new record found today with mysql_insert_id () is incorrect,
Although the source code is found to have a transaction write problem, but the most fundamental reason is that I inserted the data ID type is bigint type
The method to get MySQL new record ID value is
1. Using statements
mysql_query ("SELECT Max (ID) from user", $link);
2. Use the function msyql_insert_id ();
(1) MySQL version
int mysql_insert_id ([resource $link _identifier = NULL])
Returns the value of the field defined by Auto_increment after the last INSERT query was executed.
Returns the ID generated by the INSERT operation in the previous step. If the previous query did not produce an ID of auto_increment, then mysql_insert_id () returns 0
But when the ID is bigint, it's not working.
(2) Version mysqli
Mixed mysqli_insert_id (mysqli $link)
You can return an int or a string based on the size of the result
3. Use the query
Msyql_query ("Select last_insert_id ()");
LAST_INSERT_ID () is a MySQL function
This method solves the problem of bigint type encountered in mysql_insert_id ().
LAST_INSERT_ID () returns the ID of the auto_increment.
If the return is 0, the auto_increment is not set in the view table structure, or the function of insert delay is not used (the immediate return ID value is not returned)
Functions in the 4.PDO
public string Pdo::lastinsertid ([string $name = NULL])
Returns the ID or sequence value of the last inserted row
PHP How to get MySQL new record ID value