php - Why does json_encode return nothing? -


i learning use json on php. have db table holds records of nightclubs, , nightclub class.

so far good, no errors encountered, when want echo json_encode() doesn't show me information.

i've tried echo son_last_error(); , returned "0".

i tried using:

mysql_query('set character set utf8'); 

but did't work.

here code:

<?php  header('contennt-type: application/json'); require_once("./inc/event.inc.php"); //the boliche object require_once("./inc/connect.inc.php");//connections db  if(mysqli_connect_errno()){     printf("connect faild: %s\n", mysqli_connect_error());     exit(); } mysql_query('set character set utf8');  $query = "select * boliches id in (1,2)";  $boliche_array = array();  if($result = $dbc->query($query)) {     while($obj = $result->fetch_object())     {         printf("%s %s %s %s %s %s %s %s </br>", $obj->id, $obj->bname,$obj->place,$obj->opentime,$obj->phone,$obj->cost,$obj->age,$obj->website);          $temp_boliche = new boliche($obj->id, $obj->bname,$obj->place,$obj->opentime,$obj->phone,$obj->cost,$obj->age,$obj->website);          $boliche_array[] = $temp_boliche;  }  echo "<br /><br />";   echo '{"students":[';   $dale_data = json_encode($boliche_array[0]); echo $dale_data;   echo ',<br />';  $dale_data = json_encode($boliche_array[1]); echo $dale_data . "<br />";   echo ']}';  // close database connection $result->close(); $dbc->close();  } ?> 

and on screen

{"students":[{}, {} ]} 


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -