[Solved] Headers already sent from another page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

[Solved] Headers already sent from another page

Post by kendall »

hello,

Now usually this is a straight forward solution for me as i have done this nurmeros times however

i have a PHP process which ends with

Code: Select all

header("Location: /some/other/index.php?Msg=$Msg");
exit;
yet i get
Warning: Cannot modify header information - headers already sent by (output started at /../../../docs/index.php:22) in /../../.../docs/set_document.php on line 85
where index is the file the header redirects to and set_document is the file setting the header...

i have no spaces, however index.php does begin to output html...

but that shud be ok shudnt it? u reidrect to another page to show that html

would the fact that the resulting pages are in a frameset account for this?

Kendall
Last edited by kendall on Mon Jun 26, 2006 3:12 pm, edited 2 times in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Headers already sent for another page

Post by RobertGonzalez »

kendall wrote:
Warning: Cannot modify header information - headers already sent by (output started at /../../../docs/index.php:22) in /../../.../docs/set_document.php on line 85
Kendall
What happening at line 22 of docs/index.php? If you are not using output buffering then if anything is sent to the browser before calls to header(), session_start() or setcookie() will throw this error.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

What happening at line 22 of docs/index.php?
ahh sorry line 22 actually outputs HTML <script> tag that includes a javascript file</script>
If you are not using output buffering then if anything is sent to the browser before calls to header(), session_start() or setcookie() will throw this error.
and that is exactly my point....line 22 comes after the header being sent as line 22 is in the index.php...and index.php is what set_document.php is header() to

i had doubled check the javascript file for line space but i didnt find any

isnt that strange?

Kendall
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Is docs/set_document.php including index.php on line 85? Or perhaps vice-versa? The error is coming from docs/set_document.php on line 85 because of output starting in index.php on line 22. I am guessing that maybe there is a call to some other function that uses header() on line 85 of docs/set_document.php that comes after an output from the script.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Actualy there is something i really overlooked and understand why i get that error...yoiu are correct indexphp i being used as the main file wile setdocument is getting included my fault...gosh it didnt even show up in the product server
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Hey, at least you found it now, right? Good job.
Post Reply