I'm pulling data from a database and rearranging it in a associative array. I'm using MySQL, the db collation is utf8_general_ci.
On my development machine, when I echo json_encode($data), everything works perfectly
I imported the database onto my server, all of the same scripts etc... However, for only some results, json_ecode returns nothing, upon investigation,
echo json_last_error() === JSON_ERROR_UTF8;
returns 1.
I don't really know how to further debug, does anybody have any pointers as to what is going on here?
EDIT
I don't see how this is a duplicate, I understand the use of utf8_encode... The fact that it is working differently on separate systems is confusing me and any help would be much appreciated.
SECOND EDIT
A working example is not necessary to show that utf8_encode is needed, as it was not the correct solution. The dev mysql server was configured differrently than the remote mysql server.
The solution that worked for me was editing /etc/mysql/my.conf
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
I would gladly answer this question if it were reopened.