Problem to insert text data to mysql by PHP

When in multi byte environment, you insert text data to mysql.
sometimes it fails. case of single byte is success.
why? you make sure character set in PHP code and database it.
If difference between each other, mysql dose not to insert correct.
In this case is happen in multi byte environment.
example, PHP sjis but mysql selected utf-8.

To solve this. you use mb_convert_encoding()↓

mb_convert_encoding

mb_convert_encoding($str,'UTF-8','sjis');

above code is to convert encoding sjis to UTF-8.