SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    prevent the value change

    hello, if i insert a record into table divefile:

    PHP Code:
    mysql_query"INSERT INTO divefile(`dive_diverid`, `dive_filename`, `dive_orifilename`) VALUES('$Divername', '$filetype2','$filetype2')" );
    $new_id mysql_insert_id(); 
    and i assign the $new_id to mysql_insert_id.
    the system return the $new_id as 33 if this is the no 33 record.

    if later on the same code i insert another record into another table, the $new_id become 0, how should i prevent the value store inside $new_id change?

    many thanks.

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gohhs View Post
    hello, if i insert a record into table divefile:
    PHP Code:
    $new_id mysql_insert_id(); 
    and i assign the $new_id to mysql_insert_id.
    the system return the $new_id as 33 if this is the no 33 record.

    if later on the same code i insert another record into another table, the $new_id become 0, how should i prevent the value store inside $new_id change?
    Read the documentation @ :
    http://us2.php.net/mysql_insert_id

    The return value is the ID generated for an AUTO_INCREMENT column by the previous INSERT query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established.
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


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
  •