How to get the value of an automatically generated ID ?
I have read the following chapter of the mySQL documentation :
18.5 How to get the value of an AUTO_INCREMENT column in ODBC
but the solution given doesn't work for me !
This chapter said that just after an insert command, the following
command must be done :
but no data is selected with this command.
Here is my (php) code, flightNum is my auto_increment column :
$sql = "INSERT INTO cfdFlights (flightNum,licence) VALUES
$sql2 = "SELECT LAST_INSERT_ID()";
$result = mysql_query($sql,$conn);
$resultLast = mysql_query($sql2,$conn);
$newFlightNum = mysql_result($resultLast, 0, "flightNum");
And there is nothing in my variable $newFlightNum after that.
What can I do ?
Even if this solution works, is it a good solution ? Because if between
my insert command and my select command, another program make an insert
command, I think I have the risk to have a wrong ID...
Thanks in advance.
Grenoble Email : jacques.fournier@stripped
Other Email : jacquesf@stripped