actually the mysql_insert_id function does not take any input so you will get an error with:
$lastid = mysql_insert_id($result);
what you need to use is:
$lastid = mysql_insert_id();
this will return the id of the last inserted record and set $lastid equal to the auto increment id.