#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I have a question regarding an autoincrement insert, I would like to pull the new number that is inserted into the table immediately after the insert. Is there a way to get the number that was inserted without having to run a select to find this out. I know it is stored in the database but I cant find a function in PHP that will pull this information.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    The function for PHP you need is:

    $lastInsertedID = mysql_insert_id();

    This will give you the last inserted auto-incremented ID.

    Peter

Similar Threads

  1. Zip code validation
    By krwyth in forum MySQL Help
    Replies: 2
    Last Post: January 5th, 2004, 01:29 PM
  2. error - parent key
    By mbonfyre in forum Oracle Development
    Replies: 1
    Last Post: November 29th, 2003, 12:44 PM
  3. Accesing dates in Mysql thru PHP
    By carlmty in forum PHP Development
    Replies: 1
    Last Post: January 7th, 2003, 03:52 AM
  4. Uknow Known MYSQLERROR
    By andyw in forum MySQL Help
    Replies: 7
    Last Post: January 23rd, 2001, 09:34 AM
  5. Help! Database design
    By gerrychu in forum MySQL Help
    Replies: 4
    Last Post: December 13th, 2000, 04:07 PM

IMN logo majestic logo threadwatch logo seochat tools logo