Reputation: 155
I'm getting a query result with JSON but with special characters, It's showing NULL instead of the correct result. I've tried array_map('utf8_encode')
but I'm still getting the same error.
The code:
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["reserves"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$product = array();
array_map('utf8_encode', $product);
$product["id_reserve"] = $row["id_r"];
$product["description"] = $row["d_reserve"];
// push single product into final response array
array_push($response["reserves"], $product);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
Upvotes: 0
Views: 1049
Reputation: 20440
(Posted on behalf of the OP).
To set the array value utf-8 the function utf8_encode has to be put before the $row. The result is:
$product["description"] = utf8_encode($row["d_reserve"]);
Upvotes: 1