I'm having an accent problem when I start JSON. If I use characters like ã, õ, ô, ç, some codes appear. I do not know if it influences, but the column is Collation "utf8_general_ci". search.php :
$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: