Hi. I've previously written code like this without a problem, but now browsers seem to give me messages like this: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/jexlkzct/public_html/angloman.org/IndexProcessor.php:1) in /home/jexlkzct/public_html/angloman.org/IndexProcessor.php on line 1 Warning: Cannot modify header information - headers already sent by (output started at /home/jexlkzct/public_html/angloman.org/IndexProcessor.php:1) in /home/jexlkzct/public_html/angloman.org/IndexProcessor.php on line 38 Here is the file. Any advice would be greatly appreciated. <?php session_start();?> <?php ob_start();?> <?php // variable initialization $main = NULL; $_SESSION["interestVar"] = NULL; ?> <?php // getting form data if set and put into session if(isset($_POST["Question1"])) { $main = $_POST["Question1"]; $_SESSION["interestVar"] = $main; } // re-directing to page if ($main >= 3) { ob_end_clean(); header("Location: number.php"); exit(); } elseif ($main == NULL) { ob_end_clean(); header("Location: indexerr.html#error"); exit(); } elseif($main < 3 and $main > 0) {ob_end_clean(); header("Location: price.php"); exit();} ?>
Change <?php session_start();?> <?php ob_start();?> Code (markup): to <?php session_start(); php ob_start();?> Code (markup): The carriage returns in the source code between the ?> and <?php tags are sent to the user before your ob_start() function get executed. That's why you can't use the header() function.
Thanks for the tries guys, but neither did it. It's funny, as previous web sites have worked well. Is this something to do with newer editions of PHP? (I previously programmed in PHP4 but my ISP now uses PHP5, although my old programs still work.) How about output buffering??
Well, something is sending output to the user before your script encounters the header() function call. That's what the error message you see means. So eliminate any ?> <?php sequences and any echo()s that appear before the header() call.