header() problem

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
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

This is driving me nuts... when I try to require_once somefile that has my configuration settings then my header redirect will not work, i don't think there is anything being output when i require somehting but it just won't go.

I have checked my file and there is nothing being printed or echoed... but fact is when i rewuire that file... no work when i copy and paste all contents into where my headers are then it will work... it defeats the whole point of me having a configuration file so please help...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Are you sure there's absolutely no output in the required file - even a space before <?php will cause problems.

Mac
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

positive... what is the treshold for that though... i mean what else other than echo or print (only ones i use) that would cause this problem...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can have output even if you don't have echo or print statements - any whitespace in the file, like before the opening PHP tag (or after it) will cause problems.

Mac
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

PS. I moved this out of the sticky as it doesn't relate directly to it.

Mac
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

What do you mean by that you mean that i cannot have like
<?php

function something()
{
}
?>

because there is a space after <?php??
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHH
*takes breath*
AAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!

OMIGOSH!!!!

k thank you so much d00d...

TO EVERYONE OUT THERE!!!

Darn!! i learned this THE HARD way...spent all day cracking my head at this ... and why? because i had more lines after ?>

IF you want to keep your sanity never leave ANY space before or after the php tags <? ?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Sorry, having just reread my post I had meant to say - or after the closing tag... Glad you found the problem though.

Mac
Post Reply