7
I have accentuation problems when printing JSON. If I use characters like ã, õ, ô, ç, some codes appear. I do not know if it influences, but the column is with Collation "utf8_general_ci". php search.:
$response = array();
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
$pesq = $_GET['pesq'];
mysql_set_charset('utf8');
mysql_query('SET CHARACTER SET utf8');
$result = mysql_query("SELECT *FROM tabela WHERE titulo LIKE '%".$pesq."%'") or die(mysql_error());
if (mysql_num_rows($result) > 0) {
$response["products"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$product = array();
$product["pid"] = $row["pid"];
$product["preco"] = $row["price"];
$product["titulo"] = $row["titulo"];
$product["uf"] = $row["uf"];
$product["cidade"] = $row["cidade"];
array_push($response["products"], $product);
}
$response["success"] = 1;
echo json_encode($response);
}
else {
$response["success"] = 0;
$response["message"] = "Nenhum produto";
echo json_encode($response);
}
Return:
Table:
I think this can help you: http://answall.com/questions/23105/json-n%C3%A3o-accept-accentuate%C3%A7%C3%A3o
– Rafael Withoeft