I am working on an application which allows users to create html templates and save them.The users can use different components like text,image etc and create html pages.
Issue: The problem I am facing is,when the user enters some text with apostrophe ',I get an mysql error(obviously it should).So,I added mysql_real_escape_string to the variable before passing it to the query.It works,but I want the data back for the user to edit the site.When I try to fetch it back,there is a error as the content returned has slashes added.
I cannot use stripslashes as my content may have slashes as a part of the text entered by user.
This is how add it to the database:
 $revisionContent = mysql_real_escape_string($_POST['txtComp']);
This is the query
  $query = "insert into revision (userId,revisionContent,webId,pageId,status,saveType,dateAdded) values ('".$_SESSION['gogiUserId']."','$revisionContent','$webId','$pageId','$status','$saveType','$toDate')";         
I want the retrieved value in javascript variable,so I do it like this
 var getSavedContent = '<?php echo json_encode($IdLessContent); ?>';
But then i get this error!
    SyntaxError: missing ; before statement
     [Break On This Error]  
     ...helvetica,sans-serif;\"><strong>Text **Bo'x**(here is the apostrophe)<\/strong><\/span><\/span><\/p>\n<ol>\n...
If I remove json_encode it gives me this error for syntax.
   SyntaxError: syntax error
   [Break On This Error]     
   var getSavedContent = <div style="z-index: 1001; height: 241px; width: 725px; to...
 
    