If you want the last ID that your current script added use
$sql = "SELECT last_insert_id()";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$id = $row[0];
mysql_free_result($result);
If somebody adds to the table outside your script you'll still get the last insert you did. But note if you do a multiple insert it gives back the insert id of the FIRST insert, i.e. if the table had a current ID of 4, and you did:
insert blahblah (somefield) values (10),(12),(2);
You'd get back 5, not 7