1

I am trying to display urdu in my php basic api file but its showing me special characters.

As per other forum references, i have made characterset = utf8 and collision as well, below is the url and code of php file. please guide me what mistake am i doing here?

http://198.50.129.105/event_app_v2/get_question.php

     $conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}   


 $sql = "SELECT * FROM questions order by sequence";
    $result = $conn->query($sql);
    $data = [];
    //print_r($result);
    //exit;
    if ($result->num_rows > 0) {

        while($row = $result->fetch_assoc()) {
        $str='';
        $sql1 = "SELECT * FROM question_options where questionid=".$row["questionid"];
        $result1 = $conn->query($sql1);
        if ($result1->num_rows > 0) {
            while($row1 = $result1->fetch_assoc()) {
                $str.=$row1["options"].',';
            }
        }
            array_push($data,array(
                'questionid'=> $row["questionid"],
                'question'=> $row["question"],                
        'type'=> $row["type"],                
        'questiontype'=> $row["questiontype"],                
        'sequence'=> $row["sequence"],
        'questionnative'=>$row["questionnative"], 
        'options'=>rtrim($str,","),


                ));
        }
    } 
    if(count($data)){
         echo json_encode(['status'=>'true','data'=>$data]);
    }else{
         echo json_encode(['status'=>'true','data'=>[]]);
    }



$conn->close();
?>
UMAR-MOBITSOLUTIONS
  • 75,298
  • 95
  • 204
  • 276

0 Answers0