[SOLVED] problem with query+php+json


i have this code to search in the bd for values identically to design


$more= "design";  

$rs = mysql_query('select abcd from house where abcd like "'.$more .'%"');

$data = array();
if ( $rs && mysql_num_rows($rs) )
    while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
        $data[] = array(
            'label' => $row['abcd']  

echo json_encode($data);


In the bd i have design in the first id and design gráfico in the second id

the result is this:


if i change the bd to design grafico the result is

[{"label":"Design"},{"label":"Design grafico"}]  

so, it has some problem with the codification or what?



Did your database encoding is UTF-8 or ISO-8859-1 ?
If it is UTF-8, try

mysql_query("SET NAMES UTF8"); 

after connect to mysql.

Answered By – ntdt

Answer Checked By – Senaida (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *