Because of the way HTTP headers work, you get that error whenever you "echo" or "print" anything to the browser.
You see, because when you type in an adress, you send a series of http headers explaining what you are asking the server for. The server then replies with its own series of headers and then the content of the page. PHP allows you to manually send certain headers, but as soon as you send any output, php no longer lets you send any headers, because they will no longer work, and are likely to confuse your browser.
There are work arounds for this, using the ob functions (php.net/ob_start). But more than likely what you need to do is hunt down an "echo", "print", or "print_r"