Android Json Parsing | Php Scripts And Validate Json
I have a database in phpmyadmin panel. And I want to see this databases as json format. When I paste my link to http://jsonlint.com/. It says Null. What's wrong with my php script?
Solution 1:
You are missing a letter in the word "response" on the echo line. That's why you are getting NULL.
Replace
echo json_encode(array("server_response"=>$respose));
By this
echo json_encode(array("server_response"=>$response));
Also, you should set the header to application/json
header('Content-Type: application/json');
Final code should be:
header('Content-Type: application/json');
echo json_encode(array("server_response"=>$response));
Solution 2:
You have a typo ($respose
) in the line
echo json_encode(array("server_response"=>$respose));
which should be
echo json_encode(array("server_response"=>$response));
Post a Comment for "Android Json Parsing | Php Scripts And Validate Json"