Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1202

json_encode is returning utf-8 error on one machine but not another

$
0
0

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=utf8collation-server=utf8_general_ci

I would gladly answer this question if it were reopened.


Viewing all articles
Browse latest Browse all 1202

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>