0

I'm currently trying to save a japanese-character string with MySQL in PHP. The characters are saved as questionmarks. This is my query:

mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");

$result = mysql_query("INSERT INTO battles (basic_words) VALUES ('".mysql_real_escape_string($basic_words)."'");

The string "$basic_words" definitely contains japanese characters but they are not saved. The coalition for the row "basic_words" is utf8_general_ci

Makoto
  • 104,088
  • 27
  • 192
  • 230
Christian Strang
  • 8,470
  • 5
  • 42
  • 53

1 Answers1

3

php mysql query encoding problem suggests

$db_con= mysql_connect('localhost', 'user', 'password');
if( function_exists('mysql_set_charset') ){
    mysql_set_charset('utf8', $db_con);
}else{
    mysql_query("SET NAMES 'utf8'", $db_con);
}

Also Check http://php.net/manual/en/function.mysql-set-charset.php

Community
  • 1
  • 1
prayagupa
  • 30,204
  • 14
  • 155
  • 192