1

I am like to view the data retrieved by the SQL statement but when doing it only json_response display the data but what I want to see is echo json_encode($json_response) format of data.
I follow this tutorial but did not get the same result.
json_encode($json_response) shows no data AKA plain screen
http://www.webslesson.info/2016/05/convert-data-from-mysql-to-json-formate-using-php.html

$query = "SELECT * from LibraryEvents";

  $result = mysqli_query($connDB,$query);

  $json_response = array();
  while($row = mysqli_fetch_assoc($result)) {
        $json_response[] = $row;
        //array_push($json_response,$row_array);
  }

  echo '<pre>';
  print_r($json_response);
  echo '<pre>';
  echo json_encode($json_response);
Theo Frank
  • 17
  • 5

1 Answers1

1

Frequenty, this is due to your response having accents: if your response has accents (é, à, etc.), json_encode will not work properly.

This might help you: How to json_encode array with french accents?

Bernz
  • 171
  • 3