Reputation: 103
I'm using mysql database and php to insert russian characters into a table.
I'm using:
$conn->set_charset('utf-8');
into my .php page to set charset to utf-8 but, when I try to print the DB charset with:
echo "set name:".$conn->character_set_name();
it shows
set name:latin1
I've set my Table to:
utf8mb4_unicode_ci
but nothing change.
Printing the passed text from the ajax request, I can see the text written correctly.
What should I do?
Upvotes: 0
Views: 341
Reputation: 146460
I guess you aren't checking the return value of mysqli::set_charset()
. It must be returning false
because utf-8
is not a valid encoding name in MySQL; the correct name is utf8
(no dash). Or, even better, utf8mb4
.
You can get a list of supported encodings with:
SHOW COLLATION;
Upvotes: 2