Fooleeze Posted June 20, 2006 Share Posted June 20, 2006 I've encountered an error that as I understand is relatively common. Here it is:Warning: Cannot modify header information - headers already sent by (output started at [a href=\"http://www.*mywebsite*.com/v2/header2.php:11)\" target=\"_blank\"]http://www.*mywebsite*.com/v2/header2.php:11)[/a] in /*mywebsite*.com/v2/infoenter.php on line 108I understand this is commonly referred to the 'whitespace' error, whereas I may have unnecessary whitespace in the 'header2.php' code at line 11. Well, I've gone over this again and again, in different editors, and I cannot get past this. I can't find any extra whitespace.The 'header2.php' is just a header file that is included at the top of the 'infoenter.php' file.Here's a short version of what my code is like (infoenter.php). . . file names have been changed to protect the innocent:<?phpinclude "http://www.*mywebsite*.com/v2/header2.php";--a bunch of code--header("Location:infoverify.php?newcust=$newcust"); exit;--a bunch more code--?>That 'header2.php' file is also included in the target location (infoverify.php) in the same manner.Here is what the header2.php file looks like:<?phpinclude_once "functionsfile.php";formatthebody();print "<html><head><title>*MyWebsite.com* - Your Online Source for Sweet Stuff</title></head><table align=left valign=top width=100%><tr><td align=left><font color=green size=32><b><i>My Website</b></i></font></td></tr><tr><td>";?>So. . . anybody have any advice to help me fix my problem? Link to comment https://forums.phpfreaks.com/topic/12465-cannot-modify-header-information/ Share on other sites More sharing options...
AndyB Posted June 20, 2006 Share Posted June 20, 2006 [code]<?phpinclude "http://www.*mywebsite*.com/v2/header2.php";--a bunch of code--[/code]If that produces [b]ANY[/b] output to the browser then you'll get header errors. Link to comment https://forums.phpfreaks.com/topic/12465-cannot-modify-header-information/#findComment-47655 Share on other sites More sharing options...
Fooleeze Posted June 20, 2006 Author Share Posted June 20, 2006 Yes, it does produce output. How do I get around that? I've used this in other places to add a 'header' to my pages. However on this page (where I'm using the header:location. . . ) is where it has issues.[!--quoteo(post=386006:date=Jun 20 2006, 09:35 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 20 2006, 09:35 AM) [snapback]386006[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]<?phpinclude "http://www.*mywebsite*.com/v2/header2.php";--a bunch of code--[/code]If that produces [b]ANY[/b] output to the browser then you'll get header errors.[/quote] Link to comment https://forums.phpfreaks.com/topic/12465-cannot-modify-header-information/#findComment-47667 Share on other sites More sharing options...
AndyB Posted June 20, 2006 Share Posted June 20, 2006 header Location redirects the browser elsewhere (to another page/script) so you can check whatever condition would cause the redirect before you output anything to the browser.For example:[code]<?php$something = $_GET['some_value']; // retrieve passed value from another pageif ($something == 6) { header("Location: page6.php"); // redirect to page 6 die();} else { include("page_header.php");}... more code ...[/code] Link to comment https://forums.phpfreaks.com/topic/12465-cannot-modify-header-information/#findComment-47680 Share on other sites More sharing options...
Fooleeze Posted June 20, 2006 Author Share Posted June 20, 2006 Ok, your info pointed me in the right direction. I was putting that 'header2' file at the top (producing output) which was not necessary, so I moved it down into the 'html' section of the code. In addition I had a 'formatting' function that was also producing output, so I moved that down, too. Problem solved.Thanks a lot for your help.Todd[!--quoteo(post=386032:date=Jun 20 2006, 10:50 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 20 2006, 10:50 AM) [snapback]386032[/snapback][/div][div class=\'quotemain\'][!--quotec--]header Location redirects the browser elsewhere (to another page/script) so you can check whatever condition would cause the redirect before you output anything to the browser.For example:[code]<?php$something = $_GET['some_value']; // retrieve passed value from another pageif ($something == 6) { header("Location: page6.php"); // redirect to page 6 die();} else { include("page_header.php");}... more code ...[/code][/quote] Link to comment https://forums.phpfreaks.com/topic/12465-cannot-modify-header-information/#findComment-47698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.