Forum Moderators: coopster

Message Too Old, No Replies

Php Header Error

Help?

         

Archkiel

10:45 pm on Jul 30, 2009 (gmt 0)

10+ Year Member



I am about to go blind with rage with this error. It's the generic -

Warning: Cannot modify header information - headers already sent by (output started at /home/celendr1/public_html/main/other/staff.php:1) in /home/celendr1/public_html/header/header.php on line 5

I know exactly what causes this error - sending out header information after HTML information. I am just trying to code a redirect if a person is somewhere where they shouldn't be on the site. I even had to hack a method to give cookies, dear lord . . .

This is the code talking about these errors -

<?php

if (!isset($_COOKIE["userCookie"]) && $_SERVER['PHP_SELF'] != '/index2.php' && '/header/main_login.php')
{
header('Location: http://example.com/header/main_login.php');
}

((etc))

I have gone so far as to use a hex editor to check for spaces before the <?php tag, and there is none. My webserver uses us-ascii for when I want to edit code, as well.

If anyone has an IDEA about what this is about, my hat's off to them. Thanks so much! :3

[edited by: eelixduppy at 1:21 am (utc) on July 31, 2009]
[edit reason] example.com [/edit]

eelixduppy

1:31 am on Jul 31, 2009 (gmt 0)



Hello and Welcome to WebmasterWorld!

The code you posted is the beginning of the file? I do not see anything wrong with it here. Are you including any files anywhere that may be causing issue?

Archkiel

1:35 am on Jul 31, 2009 (gmt 0)

10+ Year Member



Yeah, there was an error in my staff file. *sighs* I was reading the error wrong - it was the STAFF page that was broken, not the header.

To be fair, I have been fighting this same sort of problem with the header.php for the last three days. If I can recreate it, I'll be sure and post it here, Thanks! This has been one hell of a headache for me. XD

And thanks for the welcome. <3

eelixduppy

1:46 am on Jul 31, 2009 (gmt 0)



Glad to see everything's sorted.

For future note you might want to look into output buffering [us3.php.net]. This way you won't run into this sort of error as often. :)