I am developing a sample app which has two textboxes that takes input from users. Now I have created a Gujarati keyboard using buttons so that user enters data in Gujarati language. When user presses Save button the data should be stored in MySQL. This is my complete code:
public void saveMy(View v)
{
name=e1.getText().toString();
no=e2.getText().toString();
try {
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http://10.0.2.2/GujaratiApp/myPHP.php");
ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("Name",name));
postParameters.add(new BasicNameValuePair("No",no));
httppost.setEntity(new UrlEncodedFormEntity(postParameters));
HttpResponse response = httpclient.execute(httppost);
Log.i("postData", response.getStatusLine().toString());
}
catch(Exception ex)
{
Log.e("log_tag", "Error: "+ex.toString());
}
}
And my PHP file is:
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("newDB");
$name = $_POST['Name'];
$no = $_POST['No'] ;
print("Name is: ".$name." And No is:".$no);
$query_add="INSERT INTO myData (`name` ,`no` ) VALUES ('$name','$no')";
$query_exec=mysql_query($query_add) or die(mysql_error());
mysql_close();
?>
Query used to create database is:
CREATE TABLE myData (name VARCHAR(20) NOT NULL,no VARCHAR(5) NOT NULL) ENGINE=INNODB CHARACTER SET= utf-8;
My data gets enter when I press Save button but in MySql i get ??? instead of Gujarati text.
when I enter English data then it works properly..