Bob
Bob

Reputation: 1385

PHP replaces anything that has a non-english character with null when pulling data from database

I pull markers' data from a MYSQL database using SQL and build up an array of markers(with attributes location, name, address, phone_number).

At the end of the script I echo json_encode($myarray).

For some reason, if say, name or address of a particular marker ends up having any French symbol(e.g. é) - PHP just replaces the entire name or address with null. Meanwhile my database tables are handling French symbols fine.

What gives?

Upvotes: 0

Views: 74

Answers (1)

colonelclick
colonelclick

Reputation: 2215

I had a similar problem with Hindi content. For me, what solved it was setting the charset to UTF-8 before the data pull. I refer you to this page on how to do that.

http://www.php.net/manual/en/mysqli.set-charset.php

Upvotes: 2

Related Questions