Christian Strang
Christian Strang

Reputation: 8530

Saving Japanese characters with PHP

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

Upvotes: 0

Views: 1810

Answers (1)

prayagupadhyay
prayagupadhyay

Reputation: 31252

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

Upvotes: 3

Related Questions