Warning: Cannot modify header information - headers already sent - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Warning: Cannot modify header information - headers already sent (/showthread.php?tid=4829) |
Warning: Cannot modify header information - headers already sent - designavenger - 02-15-2010 first off, i'm not sure if this is the correct subforum to submit this problem; apologies if it isn't. The problem is: Quote:Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\include\php_layout\admin_suite\header.php:45) in C:\xampp\htdocs\admin\admin_webmasterqueries.php on line 166 admin_suite\header.php: PHP Code: include("../include/session.php"); line 166 in delete function: PHP Code: //code executes if admin decides to delete query line 166 being: Quote:header("Location:".$session->referrer."");} I can't seem to figure out why its saying headers have already been sent? Any help would be seriously appreciated RE: Warning: Cannot modify header information - headers already sent - MattR - 02-15-2010 header() has to be called before any other output. RE: Warning: Cannot modify header information - headers already sent - designavenger - 02-16-2010 Thank you MattR for your reply. I need it to execute these three lines of code: PHP Code: $query_id = $_GET['queryID']; //Gets the querie's ID before the user is redirected, how can i make it so the header is called before input and make it run this code? RE: Warning: Cannot modify header information - headers already sent - blackstrider - 02-16-2010 Try using output buffering. Put ob_start() a line before the header and ob_flush() after the important line you want to execute so that the header will be sent later after execution. Hope this helps. RE: Warning: Cannot modify header information - headers already sent - designavenger - 02-16-2010 PHP Code: //code executes if admin decides to delete query I'm using that if that was what you meant blackstrider? Still gives me the same error, am i using it right? The three lines of code are excuting because i made it display a MySQl errror from it. Still seems to be the header code that is giving me problems RE: Warning: Cannot modify header information - headers already sent - blackstrider - 02-16-2010 Try putting ob_start() at the very first line of your php code and the other one at the very last. I'm not so sure about it but it helped me with the same error I'm having before. RE: Warning: Cannot modify header information - headers already sent - designavenger - 02-16-2010 still no joy. The .php code is working as the items are being deleted from the databse but i'm still getting the header error RE: Warning: Cannot modify header information - headers already sent - MattR - 02-17-2010 Line 45 must have some sort of output, what is line 45?? RE: Warning: Cannot modify header information - headers already sent - designavenger - 02-18-2010 I sorted it by putting: PHP Code: //code executes if admin decides to delete query and: PHP Code: <?php ob_start(); ?> thanks for the help anyways guys! |