Please can you tell me whether this is the best way of doing this -
Currently I have -
// insert data into user table
$db = connect_db();
$query = "insert load of user data in user table";
$result = mysql_query($query,$db);
// retrieve auto incremented USER_ID
$query = "SELECT USER_ID from user WHERE USERNAME='$username'";
$result = mysql_query($query,$db);
$row = mysql_fetch_array($result);
$user_id = $row["USER_ID"];
This works ok, I think. I have been using it for a few weeks. I am thinking though, that I should be using mysql_insert_id() instead, or possibly the MYSQL function LAST_INSERT_ID().
Please would you suggest the most reliable way of doing this.
Thanks in advance
Nick