php - mysql批量上传数据时的转义问题
PHP中文网
PHP中文网 2017-04-11 09:04:14
[PHP讨论组]

请教个关于sql的问题
就是我批量上传数据时(数据都是html),会发生错误,应该是有些地方需要转义。
但里面的html太多,也不知道什么地方需要转义,有没有其他办法?

update ecs_article set content='<p style="width: 700px" id="boxA">
<p style="width: 700px" id="pro_bot">
<h2 id="MCOA">Thymopoietin / TMPO Molecule Synonym Name</h2>
<p>Thymopoietin,TMPO,LAP2</p><h2 id="MCOA">Thymopoietin / TMPO Protein Products</h2>
<table width="600" cellspacing="0" cellpadding="0" class="tab01">
    <tbody>
        <tr>
            <td width="110" class="T_tit">Cat No</td>
            <td width="100" class="T_tit">Species</td>
            <td width="390" class="T_tit">Product Description</td>
        </tr><tr><td>TMO-H5129</td><td>Human</td><td><a href="http://www.acrobiosystems.com/P2150-Human-Thymopoietin--TMPO-Protein.html">Human Thymopoietin / TMPO Protein</a></td></tr></tr></tbody>
</table>
<br /><h2 id="MCOA">Thymopoietin / TMPO Molecule Background</h2>
<p style="width: 700px">Lamina-associated polypeptide 2, isoforms beta/gamma (LAP2) is also known as thymopoietin (TMPO), isoforms beta/gamma (TP beta/gamma). The thymopoetin (TMPO) gene encodes three alternatively spliced mRNAs encoding proteins of 75 kDa (alpha), 51 kDa (beta) and 39 kDa (gamma) which are ubiquitously expressed in all cells. TMPO may play a role in the assembly of the nuclear lamina, and thus help maintain the structural organization of the nuclear envelope. Also, TMPO may function as a receptor for the attachment of lamin filaments to the inner nuclear membrane. Furthermore, TMPO beta is a human homolog of the murine protein LAP2. Given the nuclear localization of the three TMPO isoforms, it is unlikely that these proteins play any role in CD90 induction.</p><h2 id="MCOA">Reference</h2><ul id="ul-bot"><li class="li-bot"><a target="new" href="http://www.ncbi.nlm.nih.gov/pubmed/18403046">(1) Shaklai S., et al., 2008, Eur. J. Cell Biol. 87:267-278.</a></li><li class="li-bot"><a target="new" href="http://www.ncbi.nlm.nih.gov/pubmed/12538639">(2) Martins S., et al., 2003, J. Cell Biol. 160:177-188.</a></li></ul><br />
<br />
&nbsp;</p>
</p>
<p>&nbsp;</p><p>&nbsp;</p>' where article_id="998";
PHP中文网
PHP中文网

认证0级讲师

全部回复(3)
高洛峰

$content=<<<STR
<p style="width: 700px" id="boxA">
<p style="width: 700px" id="pro_bot">
<h2 id="MCOA">Thymopoietin / TMPO Molecule Synonym Name</h2>
<p>Thymopoietin,TMPO,LAP2</p><h2 id="MCOA">Thymopoietin / TMPO Protein Products</h2>
<table width="600" cellspacing="0" cellpadding="0" class="tab01">
    <tbody>
        <tr>
            <td width="110" class="T_tit">Cat No</td>
            <td width="100" class="T_tit">Species</td>
            <td width="390" class="T_tit">Product Description</td>
        </tr><tr><td>TMO-H5129</td><td>Human</td><td><a href="http://www.acrobiosystems.com/P2150-Human-Thymopoietin--TMPO-Protein.html">Human Thymopoietin / TMPO Protein</a></td></tr></tr></tbody>
</table>
<br /><h2 id="MCOA">Thymopoietin / TMPO Molecule Background</h2>
<p style="width: 700px">Lamina-associated polypeptide 2, isoforms beta/gamma (LAP2) is also known as thymopoietin (TMPO), isoforms beta/gamma (TP beta/gamma). The thymopoetin (TMPO) gene encodes three alternatively spliced mRNAs encoding proteins of 75 kDa (alpha), 51 kDa (beta) and 39 kDa (gamma) which are ubiquitously expressed in all cells. TMPO may play a role in the assembly of the nuclear lamina, and thus help maintain the structural organization of the nuclear envelope. Also, TMPO may function as a receptor for the attachment of lamin filaments to the inner nuclear membrane. Furthermore, TMPO beta is a human homolog of the murine protein LAP2. Given the nuclear localization of the three TMPO isoforms, it is unlikely that these proteins play any role in CD90 induction.</p><h2 id="MCOA">Reference</h2><ul id="ul-bot"><li class="li-bot"><a target="new" href="http://www.ncbi.nlm.nih.gov/pubmed/18403046">(1) Shaklai S., et al., 2008, Eur. J. Cell Biol. 87:267-278.</a></li><li class="li-bot"><a target="new" href="http://www.ncbi.nlm.nih.gov/pubmed/12538639">(2) Martins S., et al., 2003, J. Cell Biol. 160:177-188.</a></li></ul><br />
<br />
&nbsp;</p>
</p>
<p>&nbsp;</p><p>&nbsp;</p>
STR;
$sql = "update ecs_article set content='".$content."' where article_id='998'";
高洛峰
update ecs_article set content='html代码' where article_id='998'";

转行了需要 拼接

update ecs_article set content='<p style="width: 700px" id="boxA">'+
'<p style="width: 700px" id="pro_bot">' where article_id="998";
怪我咯

htmlspecialchars

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号