Hell again,
I'm still banging my head trying to figure out the problem with my code, I did make some progress on it changing the query but the end result is not what I need. When echoing my query I should see the name of the avatar image but my result is an "S" below is the code I'm using:
<?php
$query = ("SELECT nick, avatar_img, person FROM latest_post, profile WHERE latest_post.person = profile.nick AND profile.nick = profile.avatar_img WHERE profile.avatar_img='$avatar_img'");
echo $query[$avatar_img];
?>