It seems like this line
PHP Code:
$result=mysql("$DBName","SELECT * FROM Users WHERE User='$UID'");
does not return a valid mysql result list, i.e. something went wrong on the way querying the database. You might check for that case by inserting this after the line mentioned above:
PHP Code:
if (!$result) {
echo "sth. went wrong: " . mysql_error();
}
This will print out any errors with the SQL, if there were any, it's quite useful for debugging, I use that always when I develop. The error description should give you a hint what went wrong.
BTW: I don't know of a mysql() function, so I suppose it's one you created. But you definitely don't need the double quotes around the variable $DBName.