p.s. if you don't want to go that deep by trying the join, just modify your sql statement to this:
PHP Code:
$query_title = "SELECT title FROM tablename WHERE id = '".$entryid."'";
echo $query_title;
if that still generates errors, copy that query to mysql and see if the mysql error gives you more specific info.