Well, there is a slight mistake in the way you use the arrays in your strings.
$ref[DisplayName] very likely should be $ref['DisplayName'], so:
$Level_1 = mysql_query("SELECT referrers.*,user.username
FROM referrers INNER JOIN user
ON user.id = referrers.user_id
WHERE referrers.registered_by = '$uid'
AND referrers.DisplayName ='{$ref['DisplayName']}'
ORDER BY referrers.HierarchyKey");
But this isnt the cause of the warning "mysql_fetch_array(): supplied argument is not a valid MySQL result
resource".
I suggest that you use something along the lines of:
$Level_1 = mysql_query("SELECT referrers.*,user.username
FROM referrers INNER JOIN user
ON user.id = referrers.user_id
WHERE referrers.registered_by = '$uid'
AND referrers.DisplayName ='{$ref['DisplayName']}'
ORDER BY referrers.HierarchyKey")
OR die(mysql_error());
In order to more concisely trace the error.