PHP MongoDB-> insert - fatal error with utf8

An inconvenient coding error worries about a new dataset in the mongoDB insert and stops my script if there is an encoding problem?

PHP Fatal error: Uncaught exception 'MongoException' with message 'non-utf8 string: ΓΌ' 

How to fix a new dataset before breaking a PHP driver?

Is there a better idea than utf8_encode any string data, even those that are already utf8?

+4
source share
2 answers

There was the same problem. It works:

 $string = mb_convert_encoding($string, 'ISO-8859-1', 'UTF-8'); 
+4
source

utf8_encode() ( http://php.net/manual/en/function.utf8-encode.php ), since the default PHP encoding is still not utf8, but I think (not sure about PHP 5.4).

+2
source

All Articles