kevinkhan Posted November 15, 2009 Share Posted November 15, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/181596-help-with-this-error-msg/ Share on other sites More sharing options...
Daniel0 Posted November 15, 2009 Share Posted November 15, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/181596-help-with-this-error-msg/#findComment-957878 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/181596-help-with-this-error-msg/#findComment-957914 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.