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
https://forums.phpfreaks.com/topic/209308-i-need-your-help/
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
https://forums.phpfreaks.com/topic/209308-i-need-your-help/#findComment-1092925
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
https://forums.phpfreaks.com/topic/209308-i-need-your-help/#findComment-1092926
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.