SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2007
    Location
    Florida
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using mysql_insert_id

    Hello everyone,

    I am developing a registration form using PHP to enter MySQL values across three tables and subsequently email the user an activation link. The query as it stands enters across all tables fine, but fails to send the email. After a long day, I feel like the problem is the multiple use of mysql_insert_id().

    Does anyone know how to clear out this mysql_insert_id() value so it can be used again in correlation with another query further down the script?; The the second use of the function retrieves a user id to include in the email at the end of the script.

    The script is quite large so I didn't post it, but I could provide an example if need be.

    Thanks,
    Novice at work.

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If you need to use the first value later just save it into a variable. Mysql_insert_id() will always refer to the last insert performed in the database, there is no need to clear it out.

    PHP Code:
    $lastinsert mysql_insert_id();
    ....
    // more code
    ....
    $sql "SELECT * FROM table WHERE id = $lastinsert"
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •