Does php receive json data sent by android?

Source: Internet
Author: User
Does php receive json data sent by android? Android json php

$ Response = array ();
Include ("conn. php ");
$ Conn = mysql_open ();
$ SQL = mysql_query ('set names utf8 ');
Mysql_query ($ SQL );
If (isset ($ _ POST ['name']) {...... Why does the system prompt an undefined name? The name is sent by android.


Reply to discussion (solution)

Aren't you using json? What is the content you sent? How do you know this? what is the error message? Just a prompt.

Aren't you using json? What is the content you sent? How do you know this? what is the error message? This is a prompt. thank you for your prompt. Android end
Params. add (new BasicNameValuePair ("name", name ));
JSONObject json = jsonParser. makeHttpRequest (url_up, "POST", params); sent in post mode
Why can't we get data from $ _ POST ['name'] on the php end? When debugging, I first run the android program, and then open the browser, showing that no data was received, and data was not inserted in the database.

Reply by referencing PhpNewnew on the first floor: are you not in json format? What is the content you sent? How do you know this? what is the error message? This is a prompt. thank you for your prompt. Android end
Params. add (new BasicNameValuePair ("name", name ));
JSONObject json = jsonParser. makeHttpRequest (url_u ......

Check whether the name is obtained. you can save the value to the file. Because the Android program calls your php file as soon as it is opened, and you open the file again, it must have been copied.

Run the android program first, and then open the browser.

???

Can this happen?

Reference the reply from aa77a on the second floor: reference the reply from PhpNewnew on the first floor: are you not in json format? What is the content you sent? How do you know this? what is the error message? This is a prompt. thank you for your prompt. Android end
Params. add (new BasicNameValuePair ("name", name ));
JSONObject json = jsonParser. make ......

It turns out that my android program is wrong, and the IP address in the url is wrong. But it is also strange that I saw a temporary Lan in my laptop, and then my mobile phone was connected to the network, so I wrote the IP address of the network, however, it turns out that you need to write the IP address of the network connected to the computer.

$ Data = file_get_contents ("php: // input"); to receive data, because PHP recognizes only the application/x-www.form-urlencoded standard data type by default, the text, xml, soap, and application/octet-stream types cannot be parsed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.