title: How to store CKEditor data into MySQL?
body: <p>I have CKEditor and want to send its data to the server in order to store it in MySQL. I am able to send source code (data) of CKEditor to the server with jQuery Ajax but when I try to execute my SQL query in order to store it in the database the insert command gives error. I think the main problem here is that CKEditor data contains new lines in it. How to solve this problem?</p>
  
  <p>I have found <a href="https://stackoverflow.com/questions/6430262/ckeditor-and-using-post-to-insert-into-mysql">this</a> question similar to mine, but when I tried it and it didn't work for me. And I didn't understand what does <code>mysql_prep</code> function do, because it is not standard PHP function.</p>
  
  <p><strong>update 1</strong></p>
  
  <p>The code for the HTML form is following:</p>
  
  <pre><code>$("#save").click(function(){
      var data = $( '#editor1' ).val();                                        
      $.ajax({
          type:"POST",
          url:"save.php",
          data: "editor1="+data,
          timeout:15000, 
          error:function(XMLHttpRequest, textStatus, errorThrown){
            alert("ERROR");                            
          },
          success:function(response){
            alert("Success: "+response);
          }
      });                           
  })
  </code></pre>
  
  <p>And the save.php has following codes:</p>
  
  <pre><code>&lt;?php
     include '../config.php'; //connecting to DB 
     $title='news 1'; $author=1; $date="2011/08/08"; $categories='1,2,3';     
     $short_text=$_POST['editor1']; $full_text=$_POST['editor1'];    
     $sql=sprintf('insert into news values(null,"%s",%d,"%s","%s","%s","%s")',$title,$author,$date,$short_text,$full_text,$categories);
     mysql_query($sql) or die("Error in $sql");
  ?&gt;
  </code></pre>