Everything is OK with your code and it is echoed by the PHP properly, this is the output:
<table border="0" width=100%><tr><td>Hi!</td><td align=right><a href="index.php?login">Log in!</a>, <a href="index.php?register">Register!</a></td>main
The problem is in your HTML. It's invalid. The table is not closed. The elements are messed up. The browser simply renders it in the wrong order.