Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用PHP在MySQL数据库中插入表情智能手机?_Mysql_Php - Fatal编程技术网

用PHP在MySQL数据库中插入表情智能手机?

用PHP在MySQL数据库中插入表情智能手机?,mysql,php,Mysql,Php,好吧,从相当高的解释性要求来看,这只会强化这个问题 这个应用程序有一个聊天系统,可以延迟HTML,用ajax将它发送到PHP,但是高利贷者试图在数据库中插入你设备的一些表情符号(情感),他得到的信息是:“?” 我如何改变它,以便根据它的值接收每种情绪和网站列表的某种代码 我内心有一种沉痛的感觉,如果你使用InnoDB,你会遇到字符集问题 连接到MySQL时,运行此查询 select A.variable_name, A.variable_value global_value,

好吧,从相当高的解释性要求来看,这只会强化这个问题

这个应用程序有一个聊天系统,可以延迟HTML,用ajax将它发送到PHP,但是高利贷者试图在数据库中插入你设备的一些表情符号(情感),他得到的信息是:“?”

我如何改变它,以便根据它的值接收每种情绪和网站列表的某种代码


我内心有一种沉痛的感觉,如果你使用InnoDB,你会遇到字符集问题

连接到MySQL时,运行此查询

select
    A.variable_name,
    A.variable_value global_value,
    B.variable_value session_value
from
(
    select * from information_schema.global_variables
    where variable_name like 'collation%'
) A
inner join
(
    select * from information_schema.session_variables
    where variable_name like 'collation%'
) B
using (variable_name);
我猜你会看到一个不同,尤其是与

我的建议是:使会话的值与全局值相同

select A.variable_value,B.variable_value,C.variable_value
into @coll_conn,@coll_db,@coll_srvr from
(
    select * from information_schema.global_variables
    where variable_name like 'collation_connection'
) A,
(
    select * from information_schema.global_variables
    where variable_name like 'collation_database'
) B,
(
    select * from information_schema.global_variables
    where variable_name like 'collation_server'
) C;
set session collation_connection = @coll_conn;
set session collation_database = @coll_db;
set session collation_server = @coll_srvr;
然后,您可以通过再次运行第一个查询来验证会话中的更改

试试看

注意:我之所以建议这样做,是因为上周一位开发人员向我提出了这种情况,我也进行了同样的查询。验证后,应用程序正在更改会话中的排序规则


这是一个字符集问题,而不仅仅是表情符号问题

在整个过程中使用字符集utf8mb4

  • 在客户机中
  • 在连接中(
    mysqli\u set\u charset
    或PDO等效)
  • 在表(或列)定义中
  • html标题中的

与数据库的关系不大,但我会咬一口——看看代码。不过,您必须使用PHP或类似工具进行处理。请不要关闭此操作。在这个实例中,它与数据库相关。我贴出了一个似是而非的答案。@RolandoMySQLDBA你到底是怎么看的?我在这里只能读到一句话。更详细地说:emojis需要utf8mb4,而不仅仅是utf8。