我有html string
<p><span style="color: #4f4f4f; font-family: Arial; font-size: 12px; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height:
15.600000381469727px; orphans: 2; text-align: -webkit-left; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -
webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float:
none;">Numerical estimation is key in many craft and technical jobs where the ability to
quickly and accurately estimate material quantities is essential. The speed at which you can
answer these questions is the critical measure, as most people could achieve a very high sco
re given unlimited time in which to answer. You can therefore expect 25-35 questions in 10
minutes or so.</span></p>
我想将其存储在我的database
中,但应用程序在执行查询时崩溃了。
我是否应该删除任何特定的symbol
或任何东西,或者是因为它的长度?
答案 0 :(得分:4)
您应该执行 SQL Escape 操作。
答案 1 :(得分:2)
只要你将它作为一个字符串插入就可以了。试试这个:
$htmlString = '<p><span style="color: #4f4f4f; font-family: Arial; font-size: 12px; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing: normal; line-height:
15.600000381469727px; orphans: 2; text-align: -webkit-left; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -
webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float:
none;">Numerical estimation is key in many craft and technical jobs where the ability to
quickly and accurately estimate material quantities is essential. The speed at which you can
answer these questions is the critical measure, as most people could achieve a very high sco
re given unlimited time in which to answer. You can therefore expect 25-35 questions in 10
minutes or so.</span></p>';
我基本上将""
替换为''
因为你的字符串已经包含双引号而且会破坏。
正如Ismet Alkan所说,在插入数据时执行SQL Escapes
始终是一种好习惯。
另外,请确保您的database
列与字符串兼容,因此将类型设置为TEXT
应该可以解决问题。
答案 2 :(得分:1)