-2

Possible Duplicate:
Warning: Cannot modify header information. Can't find error

a tough question. :)

I have a php script that upon a form submit verifies username and password against a DB and, if they're OK,

setcookie("call_admin_uin", $login , $expire);
setcookie("call_admin_pass", $password , $expire);

There is NO html before that. Nothing is echo-ed out and it works fine on my localhost and on one other server. Yet, when I upload it to my main server it gives out this:

Warning: Cannot modify header information - headers already sent by (output started at /home7/pnstatsc/public_html/admin/index.php:6) in /home7/pnstatsc/public_html/admin/index.php on line 72

Warning: Cannot modify header information - headers already sent by (output started at /home7/pnstatsc/public_html/admin/index.php:6) in /home7/pnstatsc/public_html/admin/index.php on line 73

So I guess there could be something wrong with the server setting... any idea what it might be?

Thanks!

Community
  • 1
  • 1
Roger
  • 6,443
  • 20
  • 61
  • 88
  • 1
    Any whitespace after the closing `?>` tag on some previously included file, perhaps? That would could as output and is commonly missed. – Wiseguy Jul 13 '11 at 14:12
  • 2
    It seems as though the error messages are telling you exactly where the problem is... e.g. You have output on **line 6** of index.php. Also the reason for the inconsistency is likely that your main server is configured to use HTTP cookies only whereas your other server(s) are not configured that way. – Brian Driscoll Jul 13 '11 at 14:12
  • Try `session_start()` right before your cookie lines. – wanovak Jul 13 '11 at 14:12
  • 1
    There is no need for HTML to trigger the error, any sort of output can trigger this, so whitespace, line breaks and all that stuff. – hakre Jul 13 '11 at 14:13
  • See the related links on the right. You find tons of questions that cover the same. – hakre Jul 13 '11 at 14:14

2 Answers2

2

There must have been some output.

You can use headers_sent to track down the file and line where headers have been sent.

Raffael
  • 19,547
  • 15
  • 82
  • 160
2

You probably have some whitespace before an opening <?php somewhere. First, I would see what the output of headers_list() is -- that will tell you which headers have been sent, then I would go through and see what headers_sent($filename) and, if necessary, headers_sent($filename, $line_number).

If you're desperate, then you can always use ob_start and buffer your output, but that is overkill.

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166