Page 1 of 1
Header already sent![solved]
Posted: Tue Jan 29, 2008 12:12 pm
by persiangulf
Yes,again this problem and this warning "header already sent". But this time I do not know why because the error occur in the first line of script(I can swear that I did not echo anything!). I use AJAX in my script and it is the first time that I front this problem.
I send the url and the data by AJAX to the php script that parse and return the result but in the first line where I include(by require_once) a script, I front a warning and be sure that there is no echo or something like this before errored line!
Re: Header already sent!
Posted: Tue Jan 29, 2008 12:19 pm
by Christopher
Make sure there are no space or newline characters characters before the <?php and after the ?> in any files. In files that contain only PHP, the ?> in not required and removing it can eliminate the problem of having hidden space or newline characters at the end of a file.
Re: Header already sent!
Posted: Tue Jan 29, 2008 12:21 pm
by JAM
You got that at the top of the page you are calling. Making sure you catch all errors that is.
Also, it's not only echo's/print's that gives you these problems. A common issue is if you have a blank row before the first <?php or if the script generates an error that's not displayed on the page itself but within the code. The later you can usually find by a 'View Source' at the generated page.
Re: Header already sent[solved]!
Posted: Tue Jan 29, 2008 12:37 pm
by persiangulf
Yes,I solved it!But the problem was not the thing that you said.The problem was the type of encoding the saved script!Your advice helped me a lot because I said to myself let me see if the encoding is not problem because I use Dreamweaver under Linux and by wine(I said to myself may be the default encoding make this problem).
Thanks a lot because of your big advice.(add encoding problem to your list

)
Re: Header already sent!
Posted: Tue Jan 29, 2008 12:42 pm
by JAM
'
C) None of the above...'-problems like this is usually found by just discussing the issue. It's hard to spot errors if you don't think out of the box.
Glad you worked it out.