-1

I realized that I have a mismatch between my stage server and the one I have localhost.
I have made some mistake with the header sent twice. Unfortunately on my localhost everything works fine but on the stage server I get a correct warning:
"Warning: Cannot modify header information - headers already sent by"...

Is this some configuration tweak on my Apache?

Stage is running on GoDaddy/linux (Apache/version?), PHP Version 5.4.19
Localhost is Apache/2.4.6, php 5.5.3-1ubuntu2.1

Edit:
Some sample code, that hopefully will clarify...
On my localhost the page is redirected every time without error, the output text "Page redirect done!" is shown on every refresh.
On the stage, this error is reported "Warning: Cannot modify header information - headers already sent by", the output text "Page redirect done!" is not shown at all.

<?php
ini_set("display_errors", true);
error_reporting(E_ALL);

if (!isset($_SESSION)) {
    session_start();
}
?>
<html><body><h1>It works!</h1>
</body></html>
<?php
if (isset($_SESSION['redirect'])) {
    unset($_SESSION['redirect']);
    echo "Page redirect done!<br><br>";
    echo "Session redirect is now unset, please update one more time to be sure!";
} else {
    $_SESSION['redirect'] = "1";
    header("Location: index.php");
}
?>

Thanks!

volt
  • 471
  • 1
  • 5
  • 12
  • I found the reason for this. I just remove the output_buffering in my php.ini and I get the same behavior as on the stage server. A very nice explanation about headers in this answer http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php/8028987#8028987 – volt Feb 13 '14 at 05:05

1 Answers1

-1

Add this at the beginning of you code ...

ini_set("display_errors", true);
error_reporting(E_ALL);

Or you just modify the php.ini manually yourself which is located somewhere on your server.

Realitätsverlust
  • 3,941
  • 2
  • 22
  • 46
  • Thanks! Isn't this about how errors are reported? I have tried this with no success. In my case the code executes without errors (the page is redirected perfectly), no errors in the log file nor to stdout. I will update the question with a code sample. – volt Feb 12 '14 at 06:34