The mysql_insert_id() function returns the AUTO_INCREMENT ID generated from the previous INSERT operation.
This function returns 0 if the previous operation does not generate an AUTO_INCREMENT ID, or FALSE on MySQL connection failure.
|connection||Optional. Specifies the MySQL connection. If not specified, the last connection opened by mysql_connect() or mysql_pconnect() is used.|
Note: Be sure to call mysql_insert_id() immediately after a query to get the correct value.
The output of the code above could be:
Your message has been sent to W3Schools.