I'm using CKEditor version 4 and all good but the problem is that when I try to save a code block of the language that is for example: HTML, C #, JavaScript, Java, etc., it does not save it in the database , when I put words with accents or with ñ if you keep them.
My code is as follows:
<script>
function insert()
{
var editorData = editor.getData();
var contenido = editorData.replace(/ /gi, ' ');
$.ajax({
type: "POST",
url: "registrar.php",
data: "contenido=" + contenido,
success: function(data)
{
alert("Registro realizado");
}
});
}
</script>
<form action="" method="post">
<textarea name="editor" id="editor" rows="10" cols="80">
</textarea>
<br>
<input type="button" value="Subir" name="boton" onClick="insert();">
<script>
var editor = CKEDITOR.replace('editor');
</script>
</form>
register.php
<?php
include_once("class.Database.php");
extract($_POST);
# contenido
$query = "INSERT INTO editor(contenido) VALUES('$contenido')";
Database::insert($query);
?>
I am using the config file of the CKEditor and I have it like that
CKEDITOR.editorConfig = function( config ) {
// Simplify the dialog windows.
config.removeDialogTabs = 'image:advanced;link:advanced';
config.language = 'es-mx';
config.entities = false;
config.basicEntities = false;
config.entities_greek = false;
config.entities_latin = false;
config.toolbarCanCollapse = true;
config.extraPlugins = 'codesnippet';
config.filebrowserUploadUrl = 'upload.php';
};
I used config.allowedContent = true;
and nothing like I could solve this ??
I have been searching and I have noticed that the character & he does not read it because when he meets that character he does not say what is missing:
For example if I put:
<
does not send anything but if I put lt;&
send <p>lt;
Then I think the problem is that he can not read that character, I've tried other characters and he can read them.
I've already tried putting config.forceSimpleAmpersand = true;
and config.forceSimpleAmpersand = false;
and does not give a solution.