I'm inserting hindi value into mysql database using php insert script
android insert code
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("data1","माऊली"));
nameValuePairs.add(new BasicNameValuePair("data2","माऊली"));
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.mydemo.com/insert.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
insert.php code
<?php
$host='100.111.111.11';
$uname='tempdata';
$pwd='tempdata';
$db="tempdata";
$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
mysql_select_db($db,$con) or die("db selection failed");
$data1=$_REQUEST['data1'];
$data2=$_REQUEST['data2'];
$flag['code']=0;
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $con);
if($r=mysql_query("insert into test values('$data1','$data2') ",$con))
{
$flag['code']=1;
}
print(json_encode($flag));
mysql_close($con);
?>
insertion is successful but values looks like ?????
If same insert.php I execute with following code '$r=mysql_query("insert into test values('$data1','$data2') ",$con)'
It display correct word 'माऊली'
any clue what need to be modify ?
0 comments:
Post a Comment