Jump to content

Problem fixing "Warning: Cannot modify header information"


A JM
Go to solution Solved by A JM,

Recommended Posts

I'm having a problem solving the following problem that I am having with the Submittal of a form. After the Submit button I am inserting records into a database and then wanting to redirect to a confirmation page but I'm getting the following error and am not sure how to resolve the problem.

 

Any suggestions of ideas I can follow?

 

Thanks.

 

AJM,

Warning: Cannot modify header information - headers already sent by (output started at /home/content/91/4761691/html/pages/claim.php:82) in /home/content/91/4761691/html/pages/claim.php on line 226
$insertGoTo = "confirm.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));

 

Edited by A JM
Link to comment
Share on other sites

The offending code does not have any echo or print functions within it but there is some echo'ing going on in some of the JavaScript..

 

I've removed the offending echo() from the javascript section and tried the page again but still get the same error, I'm confused on how to track this down.

 

The form is posting correctly as the data is written as designed I just can't get it past the header() redirect.

 

Is there an alternative on how to track down where the offending code is?

Edited by A JM
Link to comment
Share on other sites

  • Solution

I found the answer to my issues in that have multiple php tags that need to be combined and they had a blank line in between them, ugh!!!!

 

3) Make sure there is no white space outside of the php start and end tags. While a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line. This is a common culprit.

 

 

http://www.tech-recipes.com/rx/1489/solve-php-error-cannot-modify-header-information-headers-already-sent/

 

Many thanks for the suggestions and assistance.

 

AJM,

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.