Jump to content

I need your help


Recommended Posts

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());			
		}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

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.