actually, I think your do while loop is correct, though I personally would prefer a while loop, since the first mysql_fetch_assoc() is fairly unnecessary.
LordShryku, read up on the do while loop here
The error reported probably has to do with an unmatched brace, or some missing '$' etc, causing the parser to parse all the way to the end of the script, and hence reporting the error on the last line.
I cant quite find it though, could it be in an iinclude file?