I work with summernote editor when inserting text from a site into it, its design is preserved.

 $('#summernote').summernote({ height: 200, onImageUpload: function(files, editor, welEditable) { sendFile(files[0], editor, welEditable); } }); 

Then I get the html markup inside the editor block, passing it as a parameter to the handler

  textcode = $('#summernote').code(); $.ajax({ type: "POST", url: "addcode.php", data: "title="+titlearticle+"&code=" + textcode + "&preview_img="+preview_img+"&language="+language, success: function(result) { alert("Добавлено"+result); $('#summernote').code(''); } }); }) 

and write down

 include './config.php'; $title=$_POST['title']; $code=$_POST['code']; $preview_img_not_clear=$_POST['preview_img']; $preview_img=str_replace("../../imgnews/","",$preview_img_not_clear); $data=date("Ymd"); $language=$_POST['language']; $data = array( 'title' => "$title", 'code' => "$code", 'preview_img' => "$preview_img", 'data' => "$data", 'language' => "$language" ); $STH = $DBH->prepare("INSERT INTO news (title, code, preview_img,data,language) values (:title, :code, :preview_img,:data,:language)"); $STH->execute($data); echo $code; 

The problem is that if you take and just write the text, it will be saved without problems, but if you insert text with markup, it will display normally in the editor itself

 textcode = $('#summernote').code(); 

In this part, it will also output normally, but it will not be completely written into the database, but only a piece, and somehow it cuts off, each marking in different ways.

UPD Part of the problem is detected, he stopped writing when he came across a  

  • Make an encodeURIComponent for the text to be sent - Anon

1 answer 1

Well, replace the & nbsp for the space through str_replace, and all

  • I already did this, but all the same, it reacts to some characters in the same way, even though I tried htmlspecialchars and mysql_real_escape_string - zkolya