Get the unique id created after insert command of a record

This is mysql query in php code. After executing this code, the query returns latest auto generated number for that query.
$query=mysql_query(“insert into help_desk(userid,type,domain,detail) values(‘$userid’,’$type’,’$domain’,’$detail’)”);

/* Note that here auto increment field is not shown as it automatically add the next incremented value with every insert command */

echo “Your trouble ticket number is = ” mysql_insert_id();