I am using the following code to send data from my application to a PHP script on my server:
postList.add(new BasicNameValuePair("PType", TxtWeight.getText().toString()));
String StrURL="http://chacho.comuv.com/android/insert_pistachio_sell.php";
myJsonObject=JP.store_And_Feedback("PType",SpnPistachio.getSelectedItem().toString()));
DefaultHttpClient DHC=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("StrURL");
httpPost.setEntity(new UrlEncodedFormEntity(postList));
The following PHP code will store the received data in my database:
<?php
require_once "./includes/DB_Connect.php"
$PType=$_POST['PType'];
$SQL="INSERT INTO sell (ptype)VALUES ('".mysql_real_escape_string($PType)."')";
$Result=mysql_query($SQL);
?>
But data is saved in the database like "??????????"
I have searched a lot but I have not found a way to make this work properly.
Ptypekey-value pair to the postList list. Are you writing the PWeight to the database? If so does that get sent via the POST request correctly??or just non-ASCII ones? For consistent Unicode support you should use UTF-8 on both sides: usenew UrlEncodedFormEntity(postList, "UTF-8")at the client,mysql_set_charset('utf-8')at the app server and UTF-8-collated tables at the db server.