Hey all,
The title speaks for itself I suppose, but I have been having trouble finding a solution to actually inserting html into a database and then showing it again fully formatted.
Say if I have some html in a string such as:
$content = '
<strong>test</strong>
<br>
<br>
<strong>new line</strong>
';
and I try to insert it in the manor:
$data = htmlspecialchars($content, ENT_QUOTES);
$new = addslashes($data);
$SQL = "INSERT INTO tbl_test (content) VALUES ($new)";
$query = mysql_query($SQL) or die(mysql_error());
I receive:
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 '<strong>test</strong> <br> <br> <strong>new line&l' at line 2
arggh.
Any thoughts would be more than appreciated.
Further to this solution I am wanting to insert data from a WYSIWYG editor in the same way if there is anything to take into account here as well.
Thanks a bunch.