I have created a simple database table called players
:
CREATE TABLE player (
id int(10)
NOT NULL
AUTO_INCREMENT
PRIMARY KEY,
name varchar(256)
NOT NULL
);
ALTER TABLE players
CHANGE name name
varchar(256)
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
I want to insert this entry into the database '𝔸𝕝𝕠𝕟𝕖'
so I type
INSERT INTO player (name) VALUES ("𝔸𝕝𝕠𝕟𝕖")
However, when inserted, the name value becomes '???????????'
.
How can I fix this and keep my database table as efficient as possible.?
Most of the names are normal ASCII characters but sometimes I have these fancy unicode characters.
As discussed over the comments : you have correctly altered your table so the name
column accepts utf8 characters.
In this MySQL 5.7 DB Fiddle , string '𝔸𝕝𝕠𝕟𝕖'
is properly inserted and displayed.
It is very likely that the issue that you are having commes from your client, which is not properly passing data to the MySQL server.
Since you are using PHP with the mysqli extension, you can set the default client character set for the connection by using the mysqli::set_charset
function :
$conn->set_charset("utf8mb4");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.