This error almost always occurs because of a white space character outside of the php blocks on the page. Since the error is saying that the output is starting on index.php:2, this is referring to line 2 on this page. This tells me that you may have an extra space or return around this line of code on your page. If you can put the cursor next to the php block press the backspace button to see if you can remove anything without deleting the php block.
If you continue to have problems with this post back with a copy of your index page.