Odd that mysql would not complain if there were an id field in each table, but you could add to your select statement that started like
SELECT u.*, up.* FROM users AS u
and change to
SELECT u.id AS mykey,u.*, up.* FROM users AS u
then use
$id = $row['mykey']
Kind of a kludge but not sure without seeing the
DESCRIBE users
and
DESCRIBE user_profile