Quantcast
Viewing all articles
Browse latest Browse all 11

How to get AUTO_INCREMENT ID of the last MySQL Insert with PHP

Sometimes you may need to retrieve the ID of your latest record after inserting into MySQL. If you are using AUTO_INCREMENT columns for storing IDs then this is simple:

Use mysql_insert_id() function in PHP

Return Value:

- The ID generated by the latest INSERT statement OR
- 0 if no ID was generated OR
- FALSE if MySQL connection failure.

Image may be NSFW.
Clik here to view.
Share


Viewing all articles
Browse latest Browse all 11

Trending Articles