quischen Posted April 13, 2007 Share Posted April 13, 2007 Hello, I am having an issue with an php error I am receiving. I have a page that works on an older version of php running on a server which is 4.3.1. However, on another server running php version 4.4.4, that same page returns the following error. Warning: Cannot modify header information - headers already sent by (output started at /home/thegr29/public_html/headerinclude.php:6) in /home/thegr29/public_html/media_videos/retrieve.php on line 315 The page is setup so that there is a header include, a retrieve file, and a video include. The retrieve file checks for a matching city and state and includes the video include file. In the video include file, the matching city and state is then used to load the correct html which will be echoed out to the page. The actual code from line 315 of the retrieve file is: echo "<table width=\"798\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\" bgcolor=\"ffffcc\"> <tr><td width=\"570\" valign=\"top\" bgcolor=\"ffffcc\">"; if ($state == "" || $city =="") { $URL="http://www.kindervision.org"; header("Location: $URL"); } elseif ($state == "VA" && $city =="Richmond-Petersburg" ){ include("videoinclude.php"); echo "</td>"; } else { $URL="http://www.kindervision.org"; header("Location: $URL"); } Also, there is HTML being outputted to the page before the above else statement. Is this the problem? It should be noted that this same file will function correctly on the server with the older version of php (4.3.1) yet will not function on the server with the newer version of php (4.4.4). Any suggestions on how to correct this issue on the new server would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/ Share on other sites More sharing options...
boo_lolly Posted April 13, 2007 Share Posted April 13, 2007 did you look at the sticky? http://www.phpfreaks.com/forums/index.php/topic,37442.0.html at the very leasat you should google the error and see what you can find, before posting. thanks. Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/#findComment-228566 Share on other sites More sharing options...
quischen Posted April 13, 2007 Author Share Posted April 13, 2007 Yes, I did read the sticky. My issue is that I've got PHP code that works on a server that has an older version of PHP but does NOT work on a server with a newer version of PHP. Also, I am trying to narrow the problem down to whether it is logic related or server related. Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/#findComment-228630 Share on other sites More sharing options...
kenrbnsn Posted April 13, 2007 Share Posted April 13, 2007 It shouldn't work on either version. Are you absolutely sure that the code is identical? Ken Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/#findComment-228638 Share on other sites More sharing options...
quischen Posted April 13, 2007 Author Share Posted April 13, 2007 Yes, it is identical. Is there some sort of workaround I can use then if it shouldn't work on either page in order to redirect to another page instead of using the header function to accomplish this task? That is what I am trying to do if the conditions of the logic should it not work. Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/#findComment-228648 Share on other sites More sharing options...
aeafisme23 Posted April 13, 2007 Share Posted April 13, 2007 I am helping Quischen on this project and I do not think he is being quite clear so let me show you the few main pages involved with code. http://www.thegreatestsave.org/media_videos/retrieve.php?state=CA&city=Los%20Angeles WORKS http://www.thegreatestsave.org/media_videos/retrieve.php?state=kindi&city=tv (DOES NOT WORK, error) HEADER INCLUDE FILE - Basically pulls the correct header for the page. ob_start(); is present, also ob_start(); in testing we put in all files just to test to make sure it wasnt the most common error. Remember this code works perfectly well on a different server. <?php $state = $_GET['state']; $city = $_GET['city']; ?> <?php $copyright = "KinderVision® 2006-2007"; if (($state == "VA" && $city =="Richmond-Petersburg") || ($state == "ID" && $city =="Boise") || ($state == "UT" && $city =="Salt Lake City") || ($state == "NC" && $city =="Charlotte") || ($state == "kindi" && $city =="tv") || ($state == "FL" && $city =="Tampa-St. Petersburg-Sarasota") || ($state == "FL" && $city =="Jacksonville") || ($state == "ID" && $city =="Twin Falls") || ($state == "PA" && $city =="Wilkes Barre")) { ob_start(); include("header_dma.php"); } elseif ($state == "CA" && $city =="San Diego") { ob_start(); include("header_kfmb.php"); } else { ob_start(); include("http://www.thegreatestsave.org/header.php");} ?> Page 2 Retrieve.php - passes code along to Video Include Page 3, where videos and content are <?php include("../headerinclude.php"); $state = $_GET['state']; $city = $_GET['city']; $chapter1 = $_GET['chapter']; ?> <?php echo "<table width=\"798\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\" bgcolor=\"ffffcc\"> <tr><td width=\"570\" valign=\"top\" bgcolor=\"ffffcc\">"; /* Error Checking, if state or city does not exist, then exit */ if ($state == "" || $city =="") { $URL="http://www.kindervision.org"; header("Location: $URL"); } /* Chapters 1-4 WTVR */ /* RICHMOND, VIRGINIA: WTVR AND MATTRESS WAREHOUSE CHAPTER 1 */ elseif ($state == "VA" && $city =="Richmond-Petersburg" ){ include("videoinclude.php"); echo "</td>"; } // LEFT OUT other results to shorten, but the next 3 error out, the rest works <<<<<<<< /* Chapters 1-4 WBRE, PA - Wilkes Barre */ /* WBRE, PA - Wilkes Barre */ elseif ($state == "PA" && $city =="Wilkes Barre" && $chapter =="1"){ include("videoinclude.php"); echo "</td>"; } /* Chapters 1-4 KindiTV */ /* Kindi TV CHAPTER 1 */ elseif ($state == "kindi" && $city =="tv" && $chapter =="1"){ include("videoinclude.php"); echo "</td>"; } /* Chapters 1-4 Spanish TV */ /* Spanish TV CHAPTER 1 */ elseif ($state == "spanish" && $city =="tv" && $chapter =="1"){ include("videoinclude.php"); echo "</td>"; } else { $URL="http://www.kindervision.org"; header("Location: $URL"); } ?> <?php echo"</tr>"; include("../footerinclude.php"); ?> and finally..... results... Video Include.php page 3 I skipped all the other if and else if statements and showing example of assigned variables if city state requirements are met then show html etc. /* Spanish TV, Chapters 1-4 */ elseif ($state == "spanish" && $city =="tv") { $kindiclubquizlink = "http://www.kindervision.org/kindiclub/retrieve_espanol.php?state=spanish&city=tv"; $wolftrapsquizlink = "http://www.kindervision.org/wt/wt_retrieve_espanol.php?state=spanish&city=tv"; $parentsquizlink = "#"; $flashcode = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"552\" height=\"400\" id=\"spanishnocustom\" align=\"middle\"> <param name=\"allowScriptAccess\" value=\"sameDomain\" /> <param name=\"movie\" value=\"spanishnocustom.swf\" /> <param name=\"quality\" value=\"high\" /> <param name=\"scale\" value=\"exactfit\" /> <param name=\"bgcolor\" value=\"#000000\" /> <param name=\"wmode\" value=\"opaque\"> <embed src=\"spanishnocustom.swf\" quality=\"high\" scale=\"exactfit\" bgcolor=\"#000000\" width=\"552\" height=\"400\" name=\"spanishnocustom\" wmode=\"opaque\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object>"; } else { $URL="http://www.kindervision.org"; header ("Location: $URL"); } ?> <table width="794" bgcolor="#7FB497" cellpadding="0" cellspacing="0" border="0"> HTML CODE ETC ETC blah blah We're going crazy, is there a better logic to this possibly? Quote Link to comment https://forums.phpfreaks.com/topic/46883-solved-problem-cannot-modify-header-information-error/#findComment-228658 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.