mysql - Json decode string not working on php -
it working on 1 day see below json decode not working.
<?php $data = $_post["data"]; $jsonstring= urldecode(stripslashes($data)); $input = json_decode($jsonstring, true); $myfile = "testfile.txt"; $fh = fopen($myfile, 'w') or die("can't open file"); fwrite($fh, $input); fclose($fh) i have checked value of $data , $jsonstring having vaild json string. string $input empty.any suggestion...?
please check , error number , post it
echo json_encode($jsonstring, true); echo json_last_error_msg(); function json_last_error_msg() { static $errors = array( json_error_none => null, json_error_depth => 'maximum stack depth exceeded', json_error_state_mismatch => 'underflow or modes mismatch', json_error_ctrl_char => 'unexpected control character found', json_error_syntax => 'syntax error, malformed json', json_error_utf8 => 'malformed utf-8 characters, possibly incorrectly encoded' ); $error = json_last_error(); return array_key_exists($error, $errors) ? $errors[$error] : "unknown error ({$error})"; }
Comments
Post a Comment