it doesn't help to see the page if i don't know what's in the database...
try posting the entire page and we'll see if we can't spot something that's wrong elsewhere, because at the moment, i can't see any issues. i would guess it's something in the if() block you've got leading up to the data echoes.
Since I was trying to get all the commands in one page it is over 600 lines at this moment... Is gonna be a bit hard. I can remember I had this problem before, with the menu since that one is also dynamic. I cannot remember how I solved that (it was the day before yesterday

).
EDIT:
I've added the file. At line 567 starts the part of the guestbook.
At line 238 is the part where it inserts the values if you're registered.
At line 251 starts the part when you're not registered.
[attachment deleted by admin]