This is my code..!!!
i use ob_start() but still i m getting header error

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\flower\upload1.php:1) in C:\xampp\htdocs\flower\upload1.php on line 30

can anyone tell me where m i wrong.??
why this is error is related to header only..!!!
is there any other way to jump from one page to another..??


//This is the directory where images will be saved
$target = "photos/";
$target = $target . basename($_FILES['photo']['name']);

//This gets all the other information from the form
   echo $bdate;
   echo $ddate; exit();

//Writes the information to the database
mysql_query("INSERT INTO members (member_name,member_pic,member_description,member_creator,date_of_birth,date_of_death,country)
VALUES('$name', '$pic', '$about','$creator','$bdate','$ddate','India')") or die(mysql_error());

if(move_uploaded_file($_FILES['pic']['tmp_name'], $target))
else {
8 Years
Discussion Span
Last Post by sam023

there can be no output to the browser before redirects
remove the echo statements at 18 19
those statements are useless
the two possible outcomes of the upload are covered by the if statement at 26


With the ob_start statement, the echo statements shouldn't be a problem however, they are redundant.

Try putting an ob_end_clean() before the header statements to clear the buffer and turn off the buffering.

You could do the same thing with forms or buttons but it would require user intervention so this approach is better (once it works).

Edited by chrishea: n/a


when the file ends and the buffer is flushed
the result is the error noted in the op
the echo statements are before the redirect,
remove the echo and the code works
ergo error is the echo statements


I just use the echo to check value in variable and than i use exit() also which means code after exit should not run..!!
Now even after removing 'echo' my code showing Header error..!!
So i made little change in code..!! earlier i was running the query directly.. and now i put in a variable and excute it..!!

$check=mysql_query("INSERT INTO members (member_name,member_pic,member_description,member_creator,date_of_birth,date_of_death,country)
VALUES('$name', '$pic', '$about','$creator','$bdate','$ddate','India')") or die(mysql_error());
if(move_uploaded_file($_FILES['pic']['tmp_name'], $target))
else {

Now i m not getting the header error.. but now getting this error
what should i do now.?

Warning: move_uploaded_file(photos/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\xampp\htdocs\flower\upload1.php on line 26

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\xampp\tmp\phpBF.tmp' to 'photos/' in C:\xampp\htdocs\flower\upload1.php on line 26

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.