Page 1 of 1

MYSQL_INSERT_ID() Question

Posted: Tue Apr 06, 2004 2:53 pm
by brookside
Here is my code:

Code: Select all

<?php
mysql_query($insertProspective);
   $lastID = mysql_query("MYSQL_INSERT_ID()");
   $row = mysql_fetch_array($lastID);
   echo $row;
?>
With mysql_insert_id() I know it is supposed to retreive the auto-increment value inserted. Am I going wrong somewhere in my code?

What I need to do is after inserting a record into the database I need to retrieve the value of the last inserted id and store it in a variable so I can use it in subsequent insert statements.

I hope this makes sense.

Any help would be appreciated.

Posted: Tue Apr 06, 2004 3:53 pm
by brookside
nevermind i got it working.

Posted: Wed Apr 07, 2004 2:50 am
by twigletmac
brookside wrote:nevermind i got it working.
Always nice if you post the solution for others who may be looking for help on the same thing.

Mac