MySQL cannot recognize Korean characters

2019-02-28 20:29发布

问题:

I need to insert korean text to my database which is coming by url get request. However, inserted values are not recognized in MySQL. Please, need quick instruction. Thanks.

setlocale(LC_CTYPE, 'ko_KR.utf8');
mb_internal_encoding("UTF-8");    
mb_http_output('utf-8');   

$p_text = rawurldecode($_GET["text"]);

回答1:

Right after your mysql connection make this query

$mysqli->query("SET NAMES 'UTF8'");

or

mysql_query("SET NAMES 'UTF8'");

also make sure that your fields have utf8_general_ci collation



标签: php mysql encode