Jump to content

Recommended Posts

Im getting this error message when i run a script.

 

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\widgetCorp\stage5\includes\connection.php:17) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\widgetCorp\stage5\create_subject.php on line 18

 

what does this actually mean?

 

THis is the code  in create_subject.php

 

$query = "INSERT INTO subjects (
              menu_name, position, visible
              ) VALUES (
                '{$menu_name}', {$position}, {$visible}
              )";
        if(mysql_query($query, $connection))
          {
            // Success
            header("Location: content.php");
            exit; 
            // always need exit when sending header information
          }
        else
          {
          // Display error message
          echo "<p>Subject creation failed.</p>";
          echo "<p>" . mysql_error() . "</p>";
          }

 

 

Thanks for any help given..

Link to comment
https://forums.phpfreaks.com/topic/181596-help-with-this-error-msg/
Share on other sites

It means what it says: You cannot modify headers when output has been sent. That's just the way HTTP works. Headers are at the top (hence the name "header").

 

The solution: Don't output anything before you're certain you don't need to send any more headers.

And since the error message states where the output is occurring at that is preventing the headers from working -

output started at ....\connection.php:17 (line 17)

 

You would need to determine what connection.php is doing on line 17 that is producing output and either eliminate it (assuming it is unintentional) or rearrange your logic (assuming the output is intentional) so that the output occurs after the header() statement or the header() statement is before the code sending the output.

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.