使用json_encode函数时清空json字符串

I run into a very strange problem using json_encode() function in php. I have 2 tables with data. In table 1 there are just 2 rows. Using the code below works fine with json_encode() function. In table 2 I have 50,000 rows at the moment from which I select (for example 1000) rows. Using the same code doesn't lead me to a json string.

The code I am using is this:

$array = array();
while($row = mysqli_fetch_assoc($result)) {
    $array[] = $row;
}
echo count($array);
echo json_encode($array);

How can I get json_encode() working for the second table (bigger one) as well?

I found the answer to my problem: I had to change my whole encoding structure to UTF-8. So I changed:

  • the database encoding to UTF-8 (in PhpMyAdmin)
  • the table encondings to UTF-8 (in PhpMyAdmin)
  • the connection encoding with $connection->set_charset("utf8");
  • the url encoding in the java programm which fills the database (get & post data)