我制作了一个应用程序,该应用程序将很少的文本输入从android发送到我的在线数据库.我的应用程序运行良好,但是一些用户报告说他们不能使用阿拉伯文字.所以我尝试了一下,当我在数据库中发送阿拉伯文本时,它显示为?????. ?????? ??????
我的PHP脚本:
<?PHP$connect = MysqL_connect($db_host,$db_uID,$db_pass) or dIE('Could not connect');MysqL_select_db($db_name);if(MysqL_errno($connect)){dIE("Failed to connect to MysqL: " . MysqL_error());}else{ echo "success";MysqL_query("SET nameS 'utf8'"); MysqL_query('SET CHaraCTER SET utf8');}$name = isset($_POST['name']) ? $_POST['name'] : '';$sex = isset($_POST['sex']) ? $_POST['sex'] : '';$nationality = isset($_POST['nationality']) ? $_POST['nationality'] : '';$query = MysqL_query( "insert into people (name, sex, nationality) values (N'$name' ,N'$sex', N'$nationality') ", $connect);print_r($_POST);if(!$query) echo MysqL_error();MysqL_close($connect);?>
我的AndroID代码:
DefaulthttpClIEnt httpclIEnt= new DefaulthttpClIEnt(); httpPost httppost = new httpPost("http://www.xxxxxxxx.com/thescript.PHP"); Log.e("done 1st","its here"); try { ArrayList<nameValuePair> nameValuePairs = new ArrayList<nameValuePair>(); nameValuePairs.add(new BasicnameValuePair("name", name.getText().toString())); nameValuePairs.add(new BasicnameValuePair("sex", Sex.getText().toString())); nameValuePairs.add(new BasicnameValuePair("nationality", Nationality.getText().toString())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); httpResponse response = httpclIEnt.execute(httppost); Log.e("done", String.valueOf(response)); }
如您所见,我尝试了很少的东西,但没有一个起作用.
当使用插入到在线pc .PHP中时,我会得到这样的信息:
———
我的数据库设置为:
表排序规则是utf8_general_ci
它的类型是MyISAM
以及其中的列(姓名,性别,国籍):
类型是varchar,排序规则是utf8_general_ci
例如
输出应该是علي,但它是???
解决方法:
这样做
DefaulthttpClIEnt httpclIEnt= new DefaulthttpClIEnt(); httpPost httppost = new httpPost("http://www.xxxxxxxx.com/thescript.PHP"); Log.e("done 1st","its here"); try { ArrayList<nameValuePair> nameValuePairs = new ArrayList<nameValuePair>(); nameValuePairs.add(new BasicnameValuePair("name", name.getText().toString())); nameValuePairs.add(new BasicnameValuePair("sex", Sex.getText().toString())); nameValuePairs.add(new BasicnameValuePair("nationality", Nationality.getText().toString())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); //UPDATE HERE httpResponse response = httpclIEnt.execute(httppost); Log.e("done", String.valueOf(response)); }
总结 以上是内存溢出为你收集整理的php-从Android手机向在线MySQl数据库发送阿拉伯文本全部内容,希望文章能够帮你解决php-从Android手机向在线MySQl数据库发送阿拉伯文本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)