A classic situation.
If you have any session or cookie or other header-type function calls in your script, they have to be sent before anything else. As soon as the server sends out non-header data to the browser, that's the end of the header.
Make sure that nothing else is being sent - not even blank lines - before your header function calls.