extreme_heart888 Posted July 30, 2010 Share Posted July 30, 2010 i am creating a php file for my data processing but the browser return and warning message how do i correct this? please i need your help.... Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\widget_corp\includes\connection.php:9) in C:\wamp\www\widget_corp\create_subject.php on line 18 **************************************************************** content of create_subject.php file **************************************************************** <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <?php $menu_name =$_POST['menu_name']; $position =$_POST['Position']; $visible =$_POST['visible']; ?> <?php $query = "INSERT INTO subjects ( menu_name,position,visible ) VALUES ( '{$menu_name}',{$position}, {$visible} )"; if (mysql_query($query, $connection)){ header("location: content.php"); exit; }else { echo "<p>Subject creation failed.</p>"; echo "<p>".mysql_error()."</p>"; } ?> <?php mysql_close($connection); ?> ******************************************************** my connection.php file ******************************************************** <?php require("constants.php"); $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if (!$connection){ die("Database connection failed: ".mysql_errno()); } ?> <?php $db_select = mysql_select_db(DB_NAME,$connection); if (!$connection){ die("Database connection failed: ".mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/209308-i-need-your-help/ Share on other sites More sharing options...
Alex Posted July 30, 2010 Share Posted July 30, 2010 In the future when you're posting code please paste it in between [ code ][ /code ] tags (without the spaces). I've edited your post to put them in for you this time. To solve your problem remove all the whitespace before your call to header that is outside of the PHP tags (<?php ?>). This includes the whitespace in your include files. Quote Link to comment https://forums.phpfreaks.com/topic/209308-i-need-your-help/#findComment-1092925 Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2010 Share Posted July 30, 2010 output started at C:\wamp\www\widget_corp\includes\connection.php:9 (line 9) ^^^ Simple, just read the error message, then look at your connection.php code, line 9 to see why it might be sending output to the browser. You have a closing ?> php tag, followed by a new-line, then another opening <?php tag. The new-line in the file is content that is output to the browser. Why do you have that and in fact why did you put a closing php tag only to put an opening php tag after it? Quote Link to comment https://forums.phpfreaks.com/topic/209308-i-need-your-help/#findComment-1092926 Share on other sites More sharing options...
extreme_heart888 Posted July 30, 2010 Author Share Posted July 30, 2010 they teach me that way. thanks for your suggestion it solve my problem... thank you a lot.... keep up the good work.. Quote Link to comment https://forums.phpfreaks.com/topic/209308-i-need-your-help/#findComment-1092935 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.