I would create a separate table for this (confirmation_numbers or something) with an autoincrement primary key. That way you can simply insert a new record for you contact and then ask (using mysql_insert_id()) what the confirmation number is. This approach is much safer as you can be 100% sure the number is unique and it's much less complicated. (of course you still need to check if the query didn't fail) ----- http://devshed.excudo.net http://devshed.excudo.net -- View this message in context: http://www.nabble.com/mySQL-query-question-tp20495466p20501473.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php