0

I am developing w web site. Here I have included a thumnail page. It’s working well in my localhost. But when I uploaded its show me an error see

Warning: Cannot modify header information - headers already sent by (output started at /mydomain/demo1/admin/thumbnail.php:50) in /mydomain/demo1/admin/act-addVehicle.php on line 191

my code

if(move_uploaded_file ($tmpName,$path.$actual_image_name)){
                        $succ=1;
                        chmod("$add",0777);
                        $imgSucc=1; 
                            //strt image thumbnail
                        include("./thumbnail.php");
                        // ends
                        }else{ echo "Failed to upload file Contact Site admin to fix the problem"; 
                        exit;}

How I avoid this error is there any settings in php ini ?

does anyone know ? please reply

user1263260
  • 243
  • 3
  • 6
  • 17
  • You have already sent content before trying to change the headers. – Madara's Ghost Apr 28 '12 at 07:41
  • Please post the code relevant to the question. You can do so by editing your own question, and adding it there, in the body of the question. It will help us help you. – Madara's Ghost Apr 28 '12 at 07:41
  • possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php), everything you need to know here: http://stackoverflow.com/a/8028987/398242 For one thing, I don't see you using output buffering anywhere; you didn't really give enough info to help your case specifically. – Wesley Murch Apr 28 '12 at 08:03

3 Answers3

1

This kind of error typically comes from having a closing php tag in one of your file that is followed by some white space. This white space is sent to the browser when the script is executed BEFORE it executes a "header()" function.

For example, I would not be surprised that your thumbnail.php or act-addverhicule.php ends with a "?>" tag and that there is some white space after it.

As a good practice, it is always better to remove all closing php tag (the "?>") at the end of your files to avoid these kind of problems...

Gaet
  • 699
  • 3
  • 11
1

Without seeing thumbnail.php's code its hard to tell exactly what's happening, but basically its outputting something before act-addVehicle.php on line 191 is setting another header.

Most likely a single space at the end of the script. Check after ?> perhaps line 50 if just after.

You could wrap the include('thumbnail.php') into an ob_start() and ob_end_clean() but that will not solve the underlying issue of outputting before setting a new header.

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
0

of course. use ob_start funciton somewhere in the beginning of your code

heximal
  • 10,327
  • 5
  • 46
  • 69