PHP Madness!

Can someone tell me what is wrong with this? Its gotta be something small, but its driving me crazy! Thanks in advance!

<?php
$db = mysql_connect("localhost", "user","password");
mysql_select_db("theoldd_members",$db);
$checkuser = mysql_query("SELECT username FROM users WHERE 
username='$username'"); 
$username_exist = mysql_num_rows( $checkuser );
if($username_exist > 0){
   echo "I'm sorry but the username you specified has already 
been taken.  Please pick another one.";
   unset($username);
	exit();
}else{
$target_path = "uploads/memberspics/";
$_FILES['uploadedfile']['tmp_name'];
$file = $_FILES['uploadedfile']['name'];
$file = eregi_replace('[^a-z0-9A-Z./],'',$file);
$namedfile = $target_path . $file;
$target = $FILES['uploadedfile']['tmp_name'];
if(move_uploaded_file($target , $namedfile)){
	 echo "pic uploaded successfully!";
}else{
print "upload failed";
}
}
?>