0

I am making an android application but when I am sending text (My text language is Persian) to the server it shows the characters like this : (سلام به همه). And when I insert some records into Database from phpmyadmin it shows good in the database but when I retrieve it in the android side It shows like this(???????).In other words I say that when you insert something from android side it shows well on other phones but it shows bad in server side database , and when you insert manually via phpmyadmin it shows them well in the MYSQL database but it shows bad in phones.Please help me

<?php
$con=mysqli_connect("localhost","username","pass","dbname");
mysqli_select_db($con,"dbname");


$sqlQ="select * from news";
$result=mysqli_Query($con,$sqlQ);
$row=mysqli_fetch_array($result);

print $row[0];

mysqli_close($con);
?>

This is one of my PHP files , it just sends one row to the android side this is the link how it shows : [1]: http://shayea.tk/gfn.php By the way all my tables and database collations are utf8_general_ci and I tried utf8_persian_ci but it was the same

This is one of my Classes look at this too if I am doing something wrong here :

public class registerserver extends AsyncTask {


private String Link="";
private String Name="";
private String Family="";
private String User="";
private String Pass="";
private String Email="";

public registerserver(String link,String name,String family, String user ,String pass ,String email){

    Link = link;
    Name = name;
    Family = family;
    User = user;
    Pass=pass;
    Email =email;

}

@Override
protected String doInBackground(Object[] params) {
    try{

        String data = URLEncoder.encode("name" , "UTF8")+"="+URLEncoder.encode(Name ,"UTF8");
        data+="&"+URLEncoder.encode("family" , "UTF8")+"="+URLEncoder.encode(Family ,"UTF8");

        data+="&"+URLEncoder.encode("username" , "UTF8")+"="+URLEncoder.encode(User ,"UTF8");
        data+="&"+URLEncoder.encode("password" , "UTF8")+"="+URLEncoder.encode(Pass ,"UTF8");
        data+="&"+URLEncoder.encode("email" , "UTF8")+"="+URLEncoder.encode(Email ,"UTF8");
        data+="&"+URLEncoder.encode("status" , "UTF8")+"="+URLEncoder.encode("a" ,"UTF8");


        URL mylink = new URL(Link);
        URLConnection connect = mylink.openConnection();

        connect.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(connect.getOutputStream());
        wr.write(data);
        wr.flush();

        BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream()));
        StringBuilder sb = new StringBuilder();

        String line=null;
        while ((line = reader.readLine()) !=null){
            sb.append(line);
        }

        register.res=sb.toString();



    }catch (Exception e){


    }

    return "";
}
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Try [this link](http://stackoverflow.com/questions/6115612/how-to-convert-an-entire-mysql-database-characterset-and-collation-to-utf-8?answertab=active#tab-top) you may need to change database collation also you need to set php `header for UTF-8` encoding. – Noman Feb 07 '16 at 10:48
  • please explain how do you envelope and send data to server? – Ali Sheikhpour Feb 07 '16 at 10:51
  • I will edit the question and I will add one of my classes that I send data via that class please look at that class – naqib loodin Feb 07 '16 at 10:56

0 Answers0