1

私はこれを持っています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のものや何かを削除する必要があるのか​​ 、それとも長さのせいなのか、考えはありますか?

4

2 に答える 2

4

一般に、 SQL エスケープ操作を実行する必要があります。

于 2013-04-03T11:49:49.120 に答える
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>';

文字列にはすでに二重引用符が含まれており、それが壊れるため、基本的に を に置き換えました""''

SQL EscapesIsmet Alkan が述べたように、データを挿入するときに実行することは常に良い習慣です。

また、database列が文字列と互換性があることを確認してください。そのため、タイプを設定するTEXT必要があります。

于 2013-04-03T11:55:22.100 に答える