SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    json_encode returns internal server error

    Hi! I'm having a problem with this simplified code - json_encode function, to be precise.

    PHP Code:
    $arr = array('a' => 1'b' => 2'c' => 3'd' => 4'e' => 5);

    echo 
    json_encode($arr); 
    This script works on my local server without any problem, however when I upload it to my remote server, I get "500 Internal Server Error". What could be the cause of this, any ideas? Maybe some server config?

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,219
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    From php.net (though I don't see anything that should look like a 500 Internal Server Error)
    Note:

    In the event of a failure to encode, json_last_error() can be used to determine the exact nature of the error.
    Is is any more code to your file than what you pasted?

    Also check what version of PHP your server is running using phpinfo()

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Version of PHP/PECL json library matters....
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •