Look at line 49 of the code that you just posted.
Looks like this:
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE '%$find%'") or die(mysql_error());
should be:
$data = mysql_query($sql) or die(mysql_error());
Right now you aren't using the $sql variable that you used to change the sql statement.