I'm creating my db on real server but I've two big problem
1) json_encode function return "Malformed UTF-8 characters, possibly incorrectly encoded"; 2) when I fix the first problem, Japanese character is returned as '?' question mark.
but if I run same php code in localhost MAMP server, all works with success; without error.
this is PHP file
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include_once("../objects/radicale.php");
include_once("../../database/database.php");
$radicaleObj = new Radicale();
$stmt = $radicaleObj->read();
$num = $stmt->num_rows;
if($num > 0){
$radicaliArray = array();
while($row = mysqli_fetch_array($stmt)){
extract($row);
//JSON_UNESCAPED_UNICODE
echo(utf8_encode($row[1]));//<-This is the Japanese character that is returned as '?'
$age=array("Radicale"=>$radicale ,"concettoITA"=>"$concetto_ITA","Joe"=>"43");
//$concetto_ITA is the column row name extracted by extract() function and is reason of the first error
array_push($radicaliArray, $age);
}
echo(mb_convert_encoding($radicale,"UTF-8","auto"));
//echo json_encode($radicaliArray, JSON_UNESCAPED_UNICODE|JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES);
echo json_encode($radicaliArray);
// Print out the error if any
echo json_last_error_msg();
die(); // halt the script
}
?>
The character coding is utf8_general_ci both MAMP Localhost server and Netson server' database.
Can you help me? I don't know what I have to do to fix this problem.
If you need information, ask.
Thank you very much