Drav' Drav' - 1 year ago 59
PHP Question

HTTP/1.1 500 273 on certain PHP files, getting a blank page on these ones

I'm having a pretty serious issue since yesterday when I chmoded my main Apache folder (the one with my scripts etc), I think I've certainly done something wrong because some of my PHP pages won't show up and give me a blank page instead of their content, however the other ones still work.

I've checked my Apache logs and I get a "HTTP/1.1 500 273" error on all the files that show a blank page, as I get a standard "HTTP/1.1 200 2876" on all the operational pages.

I don't know what's going on, and I don't even know if it's an Apache2, a PHP, or a simple Chmod-related problem.

EDIT1: I've checked the chmod value of the concerned files to compare them to the ones that work, and they are all the same: 755

EDIT2: In fact there is just one file that is concerned. And the problem is over when I remove this little PHP code that is at its beginning:

$handle = fopen("./settings.json","r");
$settings = fread($handle, 512);
$jsonsettings = json_decode($settings, true));

function alarmonoffcheck () {
if ($jsonsettings['alarmonoff'] == 'on') {

I thought there were multiple files that were concerned because this on is used as an include in a main one, and it prevents any other PHP code from being executed, which unables the next includes in the code to work properly.

EDIT3: I've done some debugging and the line that appears to cause the problem is line number 4. I still don't get it, but at least I know where the problem is!

Answer Source

this should fix it:

$jsonsettings = json_decode($settings, true);