[SOLVED] I swear I havn't sent any headers? Please help

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
grahamcracka1
Forum Newbie
Posts: 2
Joined: Sun Jun 20, 2004 8:15 pm

I swear I havn't sent any headers? Please help

Post by grahamcracka1 »

I really want to just add a simple

header("Location: url");

to my script but it is saying that I sent headers. The file that it refers to as having sent the headers doesn't appear to have sent any, or echo'ed any text. And the line number is the very bottom line... Any help would be appreciated...
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Whitespace and blank newlines etc also count as output, check the file that claims to have sent output doesn't have any white space before or after the <?php ?> tags
crabyars
Forum Commoner
Posts: 37
Joined: Thu Jun 17, 2004 8:24 pm

Post by crabyars »

It sounds like you've already done this, but maybe triple check any include files that get called before <body> for trailing carriage returns. I had a similar problem recently and it turned out that one of includes was generating a small error message. I finally found out by moving those includes into the body so I could see what was happening. Hope this helps, let us know how it goes.

EDIT-> yeah, what James Bond said!
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Post by litebearer »

As an alternative, you could use a javascript redirect or a meta tag redirect. Both will function even if 'headers' have already been sent.
seevali
Forum Newbie
Posts: 10
Joined: Wed May 12, 2004 3:27 am

Post by seevali »

<?php
ob_start ();

?>

Use the above function on top of the page for output buffering. I think this will work.

Or else javascript can be used to redirest the page

<javascript>
location.href= URL ;
</javascript>
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

Keep away from Javascript redirects.
You can not be sure this will work for everyone (javascript disabeld).
grahamcracka1
Forum Newbie
Posts: 2
Joined: Sun Jun 20, 2004 8:15 pm

Post by grahamcracka1 »

ahh i think i had a carriage return below my ?> tag!!
Post Reply