Page 1 of 1

retreve a field from a line that was just created

Posted: Thu Mar 10, 2005 4:45 am
by Murble
Hi.

I am creating lines in my MySql DB.
I have a field called LogID that is being auto-increased.

I want to create the line, insert data to it, and know what is the number in the LogID field that was just automaticaly generated.

how can I do this???

thanx.


this is my code:

Code: Select all

$username = "master";
    $password = "passmaster";
    $database = "dbcre";

$dc_a = mysql_connect("localhost",$username,$password);
if (! $dc_a)
   die("Couldn't connect to MySQL");

$dc_b = mysql_select_db($database,$link); 
if (! dc_b)
   die("Unable to select database");


mysql_query ("INSERT INTO Log (testA, testB) VALUES ('grant', '70')");

//retreve the automatic number of field: LogID 

mysql_close($dc_a);

feyd | :roll:

Posted: Thu Mar 10, 2005 5:54 am
by anjanesh