-3

When running my script, I am getting several errors like this:

Warning: Cannot modify header information 
- headers already sent by (output started at /some/file.php:12) 
in /some/file.php on line 23

The lines mentioned in the error messages contain header() and setcookie() calls.

What could be the reason for this? And how to fix it?

Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56
bharti
  • 23
  • 1
  • 5

1 Answers1

1

This type of problem is caused when you use header after you write in your page. I assume you code might look like ::

 <html>
   <head>
     <title> title </title>
     .........
   </head>

   <body>
    .....
     <?php 
        header() // checking some header
     ?>
     .....
   </body>
 </html>

If so, use header() before html or any kind of echo or writing code. But this is not correct solutions. You can use ob_start. This is the best solution. check this

sabbir
  • 2,020
  • 3
  • 26
  • 48