Results 1 to 3 of 3

Thread: json_decode error because GET['filter'] surround by "\"

  1. #1
    Sencha Premium Member Carlos.D's Avatar
    Join Date
    Nov 2011
    Location
    Luxembourg
    Posts
    38
    Vote Rating
    1
      0  

    Default json_decode error because GET['filter'] surround by "\"

    Hi,

    When I try to json_decode() with PHP I get an error because the filter is surround by "\", when I var_dump ($_GET['filter']), I get :

    "[{\"property\":\"user_id\",\"value\":8}]"

    but PHP expecte : "[{"property":"user_id","value":8}]"

    Any idea I can solve this ?


    Thanks

  2. #2
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    763
    Vote Rating
    75
      0  

    Default

    Question is whats your JS code cause i didnt have problem decode json anytime. You can simply remove slashes by:

    Code:
    stripslashes($_GET['filter']);
    or

    Code:
    array_walk_recursive($_GET, create_function('&$val', '$val = stripslashes($val);'));

  3. #3
    Sencha Premium Member Carlos.D's Avatar
    Join Date
    Nov 2011
    Location
    Luxembourg
    Posts
    38
    Vote Rating
    1
      0  

    Default

    Thank,

    I solve this with PHP parameter :

    SetEnv MAGIC_QUOTES 0 -> in .htacess


    OR

    magic_quotes_gpc = Off -> in php.ini

Posting Permissions

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