Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8656229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:13:39+00:00 2026-06-12T15:13:39+00:00

I have a function that returns a json encoded response from a $_POST :

  • 0

I have a function that returns a json encoded response from a $_POST:

function getdatafrompost(){
    $raw  = '';     
    $httpContent = fopen('php://input', 'r');
    while ($kb = fread($httpContent, 1024))
        $raw .= $kb;        
    fclose($httpContent);      
    $params = array();
    parse_str($raw, $params);
    if (isset($params['data'])) 
        $retdata = json_decode(stripslashes($params['data']));
    else
        $retdata = json_decode(stripslashes($raw)); <====Returns Null
    return $retdata;
}

The raw data being read is:

{"recordid":"099ac8aa-0a43-11e2-860f-0016177c526f","ntsdataid":"","trkdataid":"5628af8e-08db-11e2-860f-0016177c526f","activitydate":"2012-09-29","activitytime":"10:36:21","activityname":" from S. Interrante","activitynote":"<i><font color=\"99CC00\" size=\"4\"><b><font face=\"verdana\">fgsdfgsdgsdfgsdgsdgsdfg</font>\u200b</b></font></i>"}

The problem is $retdata is returning null. This appears to be in the “activitynote” field, which contains HTML. When “activitynote” contains no HTML then data is parsed properly. Is there a better approach to parsing the data? Am I doing something incorrectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:13:40+00:00Added an answer on June 12, 2026 at 3:13 pm

    You are not supposed to use stripslashes , it would affect the validity of the json document to fix this error you should replace

    json_decode(stripslashes($raw))
    

    With

    json_decode($raw);
    

    Example

    $raw = '{"recordid":"099ac8aa-0a43-11e2-860f-0016177c526f","ntsdataid":"","trkdataid":"5628af8e-08db-11e2-860f-0016177c526f","activitydate":"2012-09-29","activitytime":"10:36:21","activityname":" from S. Interrante","activitynote":"<i><font color=\"99CC00\" size=\"4\"><b><font face=\"verdana\">fgsdfgsdgsdfgsdgsdgsdfg</font>\u200b</b></font></i>"}' ;
    var_dump(json_decode($raw));
    

    Output

    object(stdClass)[1]
      public 'recordid' => string '099ac8aa-0a43-11e2-860f-0016177c526f' (length=36)
      public 'ntsdataid' => string '' (length=0)
      public 'trkdataid' => string '5628af8e-08db-11e2-860f-0016177c526f' (length=36)
      public 'activitydate' => string '2012-09-29' (length=10)
      public 'activitytime' => string '10:36:21' (length=8)
      public 'activityname' => string ' from S. Interrante' (length=19)
      public 'activitynote' => string '<i><font color="99CC00" size="4"><b><font face="verdana">fgsdfgsdgsdfgsdgsdgsdfg</font>​</b></font></i>' (length=105)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that returns json (networks_function.php builds up some arrays and encodes
I have a php function that fetches and returns tweets data from twitter as
I have a function that returns a date from a stored procedure, and it
I have php function, that returns array to JavaScript like this: $data['first'] = 10;
I have a php page that returns json like this: while ($row = oci_fetch_array($stid,
I have a PHP script that returns a json_encoded response that is like so:
I have a function that returns two values in a list. Both values need
I have a function that returns the request parameters for each request: private function
I have a function that returns log10 values. On converting them to normal numbers,
I have a function that returns a value that can be true if the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.