Ahhh, now I get it.....(sorry)
then use the unique method...only where you attemp the first insert query, use something like this:
if (!$query = mysql_query("INSERT INTO compname (CompName) VALUES ('$compName')")){
if ($existingID = mysql_query("SELECT id FROM compname WHERE Compname='$compName'")){
$id = mysql_result($existingID, 0, 0);
}else{
print 'ERROR!';
}
}else{
$id = mysql_insert_id($query);
}
now, you have a case where if the $compName is new to the DB, it will be inserted, and you will have the var $id to pass to further forms...
otherwise, the second query tries to select the id from the database for $compName, and if that suceeds, it assigns the same $id variable the existing entry's value...if it fails, well, then you get ERROR! (or whatever)
hope this helps