0

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.

Rahul Mandaliya
  • 738
  • 1
  • 12
  • 36
  • 1
    You should first of all learn about what you're actually doing. Each step. What that means. What SQL is, how it works and that you use parametrized queries. And btw, I can not see any specific character you're talking in your title inside the question. – hakre Jan 13 '14 at 06:11
  • its <,",',> and so on inside facebook embedded post – Rahul Mandaliya Jan 13 '14 at 06:15

1 Answers1

0

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

kwelsan
  • 1,229
  • 1
  • 7
  • 18
  • what is encode64_encode ? – Rahul Mandaliya Jan 13 '14 at 06:16
  • And what exactly would be the point of this action? – tereško Jan 13 '14 at 06:27
  • You are using php and base64_encode and base64_decode functions are there.. When you are inserting HTML into DB table you will face single/duble quotes and SQL injection problem as well.. so you may save encoded data into DB.. and when you need to display it just decode it back. – kwelsan Jan 13 '14 at 06:31