seran128 Posted October 31, 2006 Share Posted October 31, 2006 I have a form that posts html code to a mysql db blob field, from a WYSIWYG editor.HOw can I get this to save if there are escape characters in the html code being posted and is there a special way of getting the code back out?the code that posts[code]$table = "webcontent_regions";$content=$_POST["test1"];$id=$_POST["id"];$sql="update $table set content='$content' where regionId='$id'";//echo $sql;$result=mysql_query($sql,$connection) or die(mysql_error());header("location: ../list/wc_list.php");[/code]The code that retrieves the data[code]function getpagecontent($inId){ global $connection; $sql="select content from webcontent_regions where regionId='$inId'"; $result=mysql_query($sql,$connection) or die(mysql_error()); while($row=mysql_fetch_array($result)) { $content=$row['content']; } echo $content;}[/code] Link to comment https://forums.phpfreaks.com/topic/25732-double-quote-and-escape-problem/ Share on other sites More sharing options...
radar Posted October 31, 2006 Share Posted October 31, 2006 First off know that you don't always need double quotes and that sometimes single slashes are more effective such as $_POST['test1'];Here is how you do it... so in the first code block... you add in$content = add_slashes($_POST['test1']);and in your function before the echo you'd add$content = strip_slashes($content);-- should work for you... Link to comment https://forums.phpfreaks.com/topic/25732-double-quote-and-escape-problem/#findComment-117481 Share on other sites More sharing options...
seran128 Posted October 31, 2006 Author Share Posted October 31, 2006 I did that and now it is posting to the db but now I have another problem.When I past html code into the WYSIWYG editor it saves fine but when i call the function that displays the code<? getpagecontent(1); ?>It shows the html code on the page and not the product of the code. Link to comment https://forums.phpfreaks.com/topic/25732-double-quote-and-escape-problem/#findComment-117491 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.