Hello guys.
I have been trying to implement an AJAX call on a database returning a JSON file with PHP and eventually met the encoding problem.
My database has some char fields with customers' names and, since it is in portuguese, european characters are pretty common. Hence the some results with those characters are returning null via JSON.
I have changed all charset settings (database, html, scripts) to UTF-8 but it is still a no go.
This is the function I use to retrieve the data:
function getJSON($sql){
$rows = array();
while($r = mysql_fetch_assoc($sql)) {
$rows[] = $r;
}
print json_encode($rows);
}
And this is my DB table structure:
conta int(10),
senha char(40),
nome varchar(30),
sobrenome varchar(25),
mail varchar(30),
saldo decimal(65,2),
agencia varchar(30),
tipo int(1),
ativa int(1),
padrao int(1)
Rows "nome" and "sobrenome" are those which primarily might contain european characters (~, ç, ´, `, etc.).
I have sought to find a function to convert the whole result array into utf8 but could not find it.
I wonder if you can bring me some light upon this problem.
Thanks.