-3

I can't use header() in any page where the session_start() is running. When I use it it says

Can't modify header information already sent by (...)

Can anyone help me for this issue?

ex3v
  • 3,518
  • 4
  • 33
  • 55
Zahirul Haque
  • 1,599
  • 17
  • 22
  • 5
    There's output somewhere else before this. Supply all the code please. – Darren Jul 22 '14 at 08:52
  • Welcome to Stack Overflow. Please read [Stack Overflow: How to ask](http://stackoverflow.com/questions/how-to-ask) and [Jon Skeet's Question Checklist](http://msmvps.com/blogs/jon_skeet/archive/2012/11/24/stack-overflow-question-checklist.aspx) to find out how to ask a good question that will generate good useful, answers. – Our Man in Bananas Jul 22 '14 at 09:52
  • Hi,I am facing now another problem that My Arabic text is not displaying. I have solved the header issue by changing the file format into normal ANSI encoding; but now If I echo Arabic data from database it shows ??????????? sign. Any suggestions? – Zahirul Haque Jul 22 '14 at 12:42

2 Answers2

0

you're printing something to the http stream before you call header. You can't do this you need to call header before any printing/echoing is done.

thenetimp
  • 9,487
  • 5
  • 29
  • 42
0

You may be getting a warning from your session_start if that's the only thing in your code, try and suppress warnings so it does not show anything else besides code output:

error_reporting(E_ERROR | E_PARSE);

Otherwise just do as others have said and make sure your code isn't outputting anything before the header is changed.

James McClelland
  • 555
  • 4
  • 16
  • Hi, Thanks everybody! I have solved the problem. I got this error for using the file format UTF-8. I am using the file for Arabic application. So, I made the format UTF-8 that sends an information before header executes. I have saved the file normally in ANSI encoding format and written the Code `` in HTML area. It has solved my problem. – Zahirul Haque Jul 22 '14 at 09:28
  • If `header()` was before the head and the meta then it should work anyway? – James McClelland Jul 22 '14 at 09:57
  • I need to use UTF-8; But If I do my page utf8 it add some code at the beginning of the page that is not shown. So, The Problem appear again in the header. – Zahirul Haque Jul 22 '14 at 13:40