MySQL插入列一半插入 [英] MySQL Insert Column Half Inserted

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

问题描述

这确实有点奇怪,可能是我没有正确完成,但出于某种原因,当我在 MySQL 中插入或更新(使用 PHP 类创建)时,由于某种原因,文本被插入(在这种情况下是电子邮件的 HTML 副本)仅插入了一半......当它看到-"时它会不断中断

This is a bit of a weird one really, and probably something I haven't done correctly, but for some reason when I am inserting or updating in MySQL (using a PHP Class to create), for some reason the text being inserted (an HTML copy of an email in this case) is only half inserted ... it keeps breaking when it sees '–'

我不认为这是标准的连字符,因为它在浏览器栏中看起来略有不同,即使在此文本区域中,我的连字符-"也比-"窄.我已经尝试过 HTML 实体,但不会转换,所以在处理这个麻烦的字符时有什么建议吗?

I do not think this is a standard hyphen since it looks ever so slightly different in the browser bar and even in this text area my hyphen '-' is narrower than '–'. I've tried HTML Entities, but will not convert, so an suggestions when dealing with this troublesome character?

虽然我应该说,如果我使用 PHP My Admin 直接插入 HTML 正文(完全相同的格式,所有内容都会被插入.我什至尝试过 str_replace 将其删除,但没有成功. 我也用更多的词替换了词,但这有效(但它仍然在该字符出现之前被切断......

Though I should probably say, if I use PHP My Admin to directly insert the HTML body (exactly the same formatting, everything gets inserted. I've even tried str_replace to remove it with no luck. I've also replaced words with a lot more words but that worked (yet it still cut off before that character showed.....

推荐答案

您正在使用破折号" 不要与连字符混淆.看看区别:--

You are using a "dash" not to be confused with a hyphen. Look at the difference: – -

破折号有很多种:

figure dash    (‒)  U+2012              
en dash        (–)  U+2013
em dash        (—)  U+2014  
horizontal bar (―)  U+2015
swung dash     (⁓)  U+2053

您可以在执行查询之前尝试 str_replace("–", "-", $query); 对每种类型执行查询,看看是否能解决您的问题,但实际上您应该研究一下做一个 utf8_encode() 然后将您的数据库字段设置为使用 UTF8.

You can try to str_replace("–", "-", $query); for each type before executing the query and see if that solves your problem, but really you should look into possibly doing a utf8_encode() and then setting your database field to use UTF8.

这篇关于MySQL插入列一半插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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