Results 1 to 3 of 3

Thread: PHP query help

  1. #1
    Join Date
    Aug 2005
    Posts
    506

    Default PHP query help

    its me again .. with another.. PHP issue...

    i am posting information to a database .. using the following

    $detail_insert = "INSERT $dbase_table2 (Id, detail_info)VALUES('', '$detail')";
    $detail_insert_q = mysql_query($detail_insert) or die(mysql_error());

    what i want to know is.. this..

    is there a way for me to get that the Id that was just created without having to do a
    SELECT Id FROM $dbase_table2 ... query...

    what i am doing is posting to multiple data bases and put the final information in the form of Id in one central Database
    Why fight Information Technology when you can outsource IT

  2. #2
    Join Date
    Jul 2004
    Posts
    264

    Default

    I am assuming that Id is an auto_increment field. If it is then you can use the mysql_insert_id() function to obtain the last id that was inserted into the table.

    Of course the function has to be used right after the execution insert query that is in question, otherwise the value will be overwritten on the next INSERT statement.

    BTW, in order for you to use an auto_increment field, it has to be an integer type, and you insert NULL for its value.

  3. #3
    Join Date
    Aug 2005
    Posts
    506

    Default

    thanks.. work .. like a charm
    Why fight Information Technology when you can outsource IT

Posting Permissions

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