android调用php操作mysql 中文乱码 用的SAE
中文插入数据库的内容是乱码数据库用的是sae的mysql字符集是utf8_general_ci这是android的代码@OverridepublicvoidonClick...
中文插入数据库的内容是乱码
数据库用的是sae的mysql
字符集是utf8_general_ci
这是android的代码
@Override
public void onClick(View arg0) {
ArrayList<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
nameValuePairs.add(new BasicNameValuePair("str",text.getText().toString()));
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://1.dong.sinaapp.com/abc.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
}
这是php的代码
<?php
$mysql = new SaeMysql();
$str = $_REQUEST['str'];
$sql2="INSERT INTO `Zuomo` (`id`,`string`) VALUES ('1','$str')" ;
$mysql->runSql($sql2);
$mysql->closeDb();
?> 展开
数据库用的是sae的mysql
字符集是utf8_general_ci
这是android的代码
@Override
public void onClick(View arg0) {
ArrayList<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
nameValuePairs.add(new BasicNameValuePair("str",text.getText().toString()));
//http post
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://1.dong.sinaapp.com/abc.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
}
这是php的代码
<?php
$mysql = new SaeMysql();
$str = $_REQUEST['str'];
$sql2="INSERT INTO `Zuomo` (`id`,`string`) VALUES ('1','$str')" ;
$mysql->runSql($sql2);
$mysql->closeDb();
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询