title: sending Special chars (String) from android to php
body: <p>My problem is that the value inserted in the database is question marks <code>???????</code> when sending string like <code>éèçà</code> or <code>يبلا</code> </p>
  
  <p>Here is my java code </p>
  
  <pre><code>private void uploadFile(String filePath) {
       try {
           try {
  
               HttpPost httpost = new HttpPost(url_upload);
               MultipartEntity entity = new MultipartEntity();
               entity.addPart("Mdp", new StringBody(mdp)); 
               entity.addPart("Msg", new StringBody("HERE IS THE STRING éçèà"));
               entity.addPart("type", new StringBody(type));
               if(type.equals("1")) {
                   entity.addPart("Emailm", new StringBody(email));
                   entity.addPart("Emailp", new StringBody(emaildest));
  
  
    }else {
                   entity.addPart("Emailp", new StringBody(email));
                   entity.addPart("Emailm", new StringBody(emaildest));
               } 
               if (attach){
                  entity.addPart("attachement", new FileBody(new File(filePath)));
                   entity.addPart("attacher", new StringBody("oui"));
               }else{
                  entity.addPart("attacher", new StringBody("non"));
              }
  
              httpost.setEntity(entity);
              HttpResponse response;
              HttpClient httpclient = new DefaultHttpClient();
              response = httpclient.execute(httpost);
  
              if (response != null) {
                  HttpEntity entity2 = response.getEntity();
                  String responseString = EntityUtils.toString(entity2, "UTF-8");
                  System.out.println(responseString);
                  json2=new JSONObject(responseString);
  
              } else { //erreur
              }
          } catch (IOException e) {
              e.printStackTrace();
          }
      }catch (Exception e){
  
      }
    }
  </code></pre>
  
  <p>the php code</p>
  
  <pre><code> &lt;?php  
      date_default_timezone_set ("Africa/Algiers");
      include('connect.php');
       $response = array();
  
      if (isset($_REQUEST['Emailm'])&amp;&amp; isset($_REQUEST['Mdp'])&amp;&amp;isset($_REQUEST['type']) &amp;&amp;     isset($_REQUEST['Emailp'])&amp;&amp;isset($_REQUEST['Msg'])  ) {
  
  
       $Emailm = $db-&gt;real_escape_string($_REQUEST['Emailm']);  
       $Emailp = $db-&gt;real_escape_string($_REQUEST['Emailp']); 
       $Mdp = $db-&gt;real_escape_string($_REQUEST['Mdp']);  
          $Msg=$db-&gt;real_escape_string($_REQUEST['Msg']);
          $Mdp = $_REQUEST['Mdp'];  
        $type= $_REQUEST['type'];
       $target_path1 = "attachement/";  
  
  
      if($type=="0"){  //compte patient
      if ($result = $db-&gt;query("SELECT * FROM `patient` WHERE `Email_p`='$Emailp' AND `Mdp`='$Mdp'")) {
      $row_cnt = $result-&gt;num_rows; }
  
      }else {  //compte médecin
      if ($result = $db-&gt;query("SELECT * FROM `med` WHERE `Email`='$Emailm' AND `Mdp`='$Mdp'")) {
      $row_cnt = $result-&gt;num_rows; } 
      }
  
  
      $b=false;
      $a=false;
  
      if ($row_cnt&gt;0) {  
                  if($_REQUEST['attacher']=="oui"){   
                  $filecount = 0;
                  $files = glob($target_path1 . "*");
                  if ($files){
                  $filecount = count($files);
                  }
                  $nomFichier=$filecount.basename( $_FILES['attachement']['name']) . ".a"; 
                  $target_path1 = $target_path1 . $nomFichier;
                  $nomFichierOrigin=basename( $_FILES['attachement']['name']);
                  if(move_uploaded_file($_FILES['attachement']['tmp_name'], $target_path1)) {
                  $b=true;} 
                  }
                  else{
                  $nomFichier="";
                  $nomFichierOrigin="";
                  };
  
                         $h=new DateTime("now") ;
                         $s=$h-&gt;format('G:i:s');
                         $s2=$h-&gt;format('Y-m-d');
                      if($result = mysqli_query($db,"INSERT INTO `msg`(`cle`, `email_m`, `email_p`, `message`, `attachement`, `type`, `attachementNomOrigin`, `heure`, `date`,`vu`) 
                      VALUES ('','$Emailm','$Emailp','$Msg','$nomFichier','$type','$nomFichierOrigin','$s','$s2','non')"))
                      {$a=true;}
  
                      if($a==true &amp;&amp; $b==true &amp;&amp; $_REQUEST['attacher']=="oui"){
                       $dernierId = $db-&gt;insert_id;   
                       if ($result = $db-&gt;query("SELECT * FROM `med` WHERE `Email`='$Emailm' AND `Mdp`='$Mdp'")) {
                       if (mysqli_num_rows($result) &gt; 0) { 
                        $response["Msg"] = array();
                       while ($row = mysqli_fetch_array($result)) {
                      $Msg = array();
                      $Msg["cle"] = intval($row["cle"]);
                      $Msg["heure"] = $row["heure"];
                      $Msg["date"] = $row["date"];
                      $Msg["email_m"] = $row["email_m"]; 
                      $Msg["email_p"] = $row["email_p"]; 
                      $Msg["message"] = $row["message"]; 
                      $Msg["type"] = $row["type"];  
                      $Msg["attachement"] = $row["attachement"]; 
                      $Msg["attachementNomOrigin"] = $row["attachementNomOrigin"]; 
                      array_push($response["Msg"], $Msg);
                       }
  
                      $response["success"] = 1;
                      $response["message"] = "Succès";
                      }}} else 
  
                      if($a==true &amp;&amp; $_REQUEST['attacher']=="non"){
                      $response["success"] = 1;
                      $response["message"] = "Succès"; 
                      }else{
  
                      $response["success"] = 0;
                      $response["message"] = "Erreur lors de l'envoi";
                      }
  
                      echo json_encode($response);
         } else { 
          $response["success"] = 0;
          $response["message"] = "Email ou Mot de passe incorrect";
  
          echo json_encode($response);
        }
        }else { 
       $response["success"] = 0;
       $response["message"] = "Champs manqués";
  
        echo json_encode($response);
        }
        ?&gt;
  </code></pre>
  
  <p>and here the connect.php</p>
  
  <pre><code> &lt;?php 
   $db = new mysqli('localhost', 'root', '', 'rechmed'); 
   mysqli_set_charset($db,'utf8');   
   ?&gt;
  </code></pre>
  
  <p>thank you so much, i spent days looking for a way to solve this ..</p>