Topic: PHP (MediaWiki) Cannot modify header (Read 732 times)

  • Avatar of IceSage
  • Follower of the Foget since 2000
  • PipPipPip
  • Group: Premium Member
  • Joined: Jun 10, 2002
  • Posts: 306
Well, I was screwing around with the main index.php file. I added a piece of code, ran the script. I got this error:


Warning: Cannot modify header information - headers already sent by (output started at /home/content/i/c/e/icesage1984/html/drequiem/drwiki/index.php:2) in /home/content/i/c/e/icesage1984/html/drequiem/drwiki/includes/OutputPage.php on line 570

Warning: Cannot modify header information - headers already sent by (output started at /home/content/i/c/e/icesage1984/html/drequiem/drwiki/index.php:2) in /home/content/i/c/e/icesage1984/html/drequiem/drwiki/includes/OutputPage.php on line 571

I removed the line and put the file exactly how it was... And, I STILL get this error.

I know a little PHP, I'm just not savvy when it comes to figuring out the most basic of errors from other peoples scripts.

Any help would be appreciated.
  • Avatar of dom
  • Chapter Four: The Imagination And Where It Leads
  • PipPipPipPipPipPipPip
  • Group: Premium Member
  • Joined: Nov 9, 2003
  • Posts: 1022
You might have accidentally put some whitespace at the top of the page.

If not, upload the file somewhere and we can check it out
  • Avatar of losl
  • PARTY HARD K
  • Group: Member
  • Joined: Aug 3, 2003
  • Posts: 9
Because of the way HTTP headers work, you get that error whenever you "echo" or "print" anything to the browser.

You see, because when you type in an adress, you send a series of http headers explaining what you are asking the server for. The server then replies with its own series of headers and then the content of the page. PHP allows you to manually send certain headers, but as soon as you send any output, php no longer lets you send any headers, because they will no longer work, and are likely to confuse your browser.

There are work arounds for this, using the ob functions (php.net/ob_start). But more than likely what you need to do is hunt down an "echo", "print", or "print_r"
  • Avatar of IceSage
  • Follower of the Foget since 2000
  • PipPipPip
  • Group: Premium Member
  • Joined: Jun 10, 2002
  • Posts: 306
Thanks for the explaination, Losl.

And, it was the one line of whitespace I had. >_>

Thanks for the replies you two.