Of all the options above I would use
if (mysql_num_rows($result)==0) { PERFORM ACTION }
checking against the result like below
if (!$result) { PERFORM ACTION }
This will be true if a mysql_error occurs so effectively if an error occurred you could then enter a duplicate user-name...