duanduo3712 2014-01-13 05:32
浏览 29

如何使用php [duplicate]在mysql数据库中插入特定字符

This question already has an answer here:

I want to insert Facebook Embedded Post in to mysql database table EMBEDDED_POST_MASTER.

My Facebook Embedded Post is:

<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-post" data-href="https://www.facebook.com/photo.php?fbid=634747619920534&amp;set=a.541467239248573.1073741828.523671034361527&amp;type=1" data-width="466"><div class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/photo.php?fbid=634747619920534&amp;set=a.541467239248573.1073741828.523671034361527&amp;type=1">Post</a> by <a href="https://www.facebook.com/SilkyQuoteOfficial">SilkyQuote</a>.</div></div>

When i am inserting this embedded post into table its gives error like :

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'div id=\"fb-root\">

I also use $insert_data = mysql_real_escape_string($input_data);

but it is not working, still same error comes, when i insert without embedded post then its inserted successfully.

means the error accure only when i insert Embedded post.

</div>
  • 写回答

1条回答 默认 最新

  • duankangzi766767 2014-01-13 05:44
    关注

    Before insert HTML into MYSQL DB, you can encode it with base64_encode.. That will help you to deal with database.

    评论

报告相同问题?

悬赏问题

  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害