Vit Kos
Vit Kos

Reputation: 5755

json_encode() in PHP returns null values for russian

strange problem occurs with json_encode(). I have some text in mysql database in russian. The text fields in DB are encoded in utf8-general-ci. when executingecho json_encode($this->result); all the text that is in russian becomes "null"

Any ideas? Thank you in advance

Upvotes: 0

Views: 1237

Answers (1)

Pekka
Pekka

Reputation: 449485

When json_encode() encounters a string that contains an invalid (= non-UTF-8) character, it drops the entire string silently.

Most likely your database connection is not UTF-8 encoded. See this question on how to fix that.

Upvotes: 2

Related Questions