无法在MySQL中插入度数符号 [英] Unable to insert degree symbol in MySQL

查看:83
本文介绍了无法在MySQL中插入度数符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我插入度数符号而不是将其保存时使用PHP输入表格,因为它在MySQL中显示为"°",例如,如果我编写"37°C",则将其另存为"37°C"

Using a PHP entry form when I insert the degree symbol instead saving it as it's diplayed the value in MySQL is "°", for example if I write "37°C" it is saved as "37°C"

这是我的代码示例

<input class="form-control" type="text" name="inc" placeholder="48 Hrs Aerobic, 37°C" value="48 Hrs Aerobic, 37°C">

从数据库中获取数据时,该字符也显示为"°C".

The character is also shown as "°C" when the data is fetch from the DB.

推荐答案

这是因为MySQL数据库的编码格式.请将其设置为以下内容之一,并确保标题也显示UTF-8:

It is because of the encoding format of your MySQL database. Please set it to one of the following and make sure your headers say UTF-8 too:

utf8_general_ci
utf8_unicode_ci
utf8mb4_general_ci
utf8mb4_unicode_ci

按上述顺序进行.

如果需要,在您的PHP中:

And in your PHP, if needed:

header('Content-Type: text/html; charset=utf-8');

如果其他所有操作失败,请将°转换为&deg;,然后由浏览器确定.

If everything else fails, convert ° to &deg; and let the browser decide it.

这篇关于无法在MySQL中插入度数符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆