I’m doing a JsonP request to a php script hosted on a website i have.
The php script get results from DB and return them as Json.
The problem is that the DB contains Hebrew chars and i get them as ‘??????’ in the response.
Any idea how to solve this?
Here is the js code:
$.getJSON("http://flyfish.co.il/appdiet?callback=?",function(data){
$('p').text(data[0].food_name);
});
and the php code:
<?php
header('Content-type: text/html; charset=UTF-8');
require_once 'config.php';
$mysqli = new mysqli(HOST,USERNAME,PASSWORD,DB_NAME);
$query = "SELECT * from mytable";
if ($result = $mysqli->query($query))
{
$data = array();
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
echo $_GET['callback'].'('.json_encode($data).')';
}
else {
echo $_GET['callback'].'('.$mysqli->error.')';
}
$mysqli->close();
Try adding a
set names 'utf8';before yourselectstatement.