PS: My preferred method is to define the column as UNIQUE in your table definition, then look for a MySQL error 1062 if it's a duplicate entry:
$sql = "INSERT INTO ...........";
$result = mysql_query($sql);
if(!$result)
{
if(mysql_errno() == 1062)
{
// output error message here for duplicate value
}
else
{
die("Query failed: $sql - " . mysql_error());
}
}
This way you only have to do one query instead of two.