You are not logged in.

#1 2010-12-11 16:50:10

jocom
Member
Registered: 2009-04-29
Posts: 74

[solved] JSON not working with Apache and PHP

Hi,

My installation of Apache and PHP work fine, I did everything as written in the LAMP page on ArchWiki.
Now I wanted to use json_encode(), so I deleted the comment ";" in front of extension=json.so in my php.ini.
But after restarting httpd, it doesn't render PHP anymore. It serves me with a pop-up screen as if I wanted to download the *.php.
Howcome this strange behaviour? I hope one of you can enlighten me.

edit: obviously, in my error.logs I find a Fatal error: Call to undefined function json_encode(). But I thought it was built in, since PHP 5.2...

jocom

Last edited by jocom (2010-12-13 11:49:38)

Offline

#2 2010-12-13 08:18:13

jocom
Member
Registered: 2009-04-29
Posts: 74

Re: [solved] JSON not working with Apache and PHP

Ok, I discovered it isn't

;extension=json.so

that caused the problem. It is because of the header I try to send.

header("Content-type: application/json; charset="utf-8");

Any idea what's wrong with that?

Offline

#3 2010-12-13 09:19:23

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [solved] JSON not working with Apache and PHP

You have 3 doublequotes?


ᶘ ᵒᴥᵒᶅ

Offline

#4 2010-12-13 11:49:19

jocom
Member
Registered: 2009-04-29
Posts: 74

Re: [solved] JSON not working with Apache and PHP

litemotiv wrote:

You have 3 doublequotes?

Actually, that was a typo...

The whole problem is, that Firefox doesn't recognize "application/json", so it works, if I totally remove the header declaration, or change it to "text/plain".

Offline

Board footer

Powered by FluxBB