views:

1428

answers:

3

Hi,

when trying to log-in at this site (user:polopolo,pass:samara) the result is a blank page. I know that the problem is with the sending of headers and the *ouput_buffering* in the php.ini file. I had the same problem on another host but the problem was fixed when I changed *output_buffering= On*. It doesn't work on the current host and I wonder why? Any suggestions?

-the phpinfo of the current site.


Edit: Problem solved. I reverse-engineered the code and found some additional spaces after the php closing tag, before the sending of the headers. The code wasn't written by me and I instinctively ignored this option as the whole system worked already on another server. But my colleague did some changes I was unaware of...The lesson learned: teamwork is important and don't let anybody do the thinking for you. Still it is a mystery to me how come after trying everything to display errors and especially the "Cannot modify headers" they didn't display properly. I did everything you advised me to do- display errors, log them and so on...anyway thanks.

+1  A: 

I'm no expert and I can't understand what output buffering as to do with anything, maybe there are some errors in the code?

Could you create an .htaccess file with the following content:

php_flag display_errors on
php_value error_reporting 30719

Place it in the root folder of that site and then try to log in again to see if there are any output errors?

Nazgulled
tried it. no errors occur. I don't think that it is supposed to be and error it something with the crappy headers that I don't understand. ty though
chosta
Sorry I can't be of more help but you could please try again but instead of 7, use 30719 and comment here when it's done so I can test it if you don't mind?
Nazgulled
I don't think the changes are in place because looking at phpinfo() doesn't show the supposed values ("On" for display_errors; "30719" for error_reporting)
Nazgulled
Try setting this in your php.ini file rather than in an .htaccess file. You'll probably find that these settings are already in that file and you just need to change them. But also heed my warning that it is generally unsafe to expose error messages on a server available to the public - it's better to diagnose this on a test server only you have access to.
thomasrutter
+2  A: 

Presumably, the page you hit immediately after logging in does a redirect.

Doing a redirect requires outputting an HTTP header with the response. The problem is, if PHP has already begun outputting the body of the document, it cannot then output a header because they headers ended when the body started.

Output buffering prevents PHP from outputting any part of the body of the document until the output buffer is flushed (or PHP exits). This allows you to output headers at any time.

Now, if turning output buffering on fixed the problem on own site/server, but not on another, that's a clear indication that it isn't actually the same problem - you are encountering a different problem.

You should be logging PHP errors, so check your PHP error log. If (and only if) you are viewing this on a restricted developers-only site (which you aren't), you may turn on display_errors in your PHP configuration, which will display errors on the page as it is rendered. This is generally considered an unsafe setting on publicly accessible servers, because of the potential for attackers to try and cause an error for which the error message reveals some private information.

thomasrutter
A: 

I had also got the same problem while working on a project. I fixed it later by setting output_buffering = 4096 in php.ini configuration file and it worked fine in localhost but when i put it on host server, i got this error again. I am not sure how to use my own php.ini configuration file on host server. Any suggestion are welcome...

Shashi