Search code examples
javascriptphphtmlmysqlwysiwyg

My data does not get posted in the database when using tinymce editor


I really need help as this is actually the first time I'm using a wysiwyg editor on a site. This is the code for the textarea: <textarea title="news" id="news" name="news" class="form-control col-md-7 col-xs-12"></textarea> and that of tinymce integration:

<script>
        tinymce.init({
            selector: '#news',
            browser_spellcheck: true,
            branding: false,
            height: 400,
            menu: {
                file: {title: 'File', items: 'newdocument'},
                edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall'},
                insert: {title: 'Insert', items: 'link media | template hr'},
                view: {title: 'View', items: 'visualaid'},
                format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
                table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'},
                tools: {title: 'Tools', items: 'spellchecker code'}
            },
            menubar: 'file edit insert view format table tools help',
            toolbar: ['undo', 'redo','searchreplace', 'preview'],
            plugins: [ 'code', 'lists', 'autolink', 'preview', 'searchreplace', 'wordcount'],
            encoding: 'xml'
        });
    </script>

my issue now is that when i try to insert the values into the database, it inserts the first time but does not insert consecutive values. This is my code for insertion:

$ins->insert('headline', array('id'=>'','post_id'=>$pi_id,'post_cat'=>$cat,'post_title'=>$title,'post_cont'=>$content));

Also i allowed $content which is the value of the textarea to pass through some functions like striptags and htmlentities, i print out the values of $content after submission and it displays it in xml which i don't see as a problem. the only issue i've got is it does not display consecutive data in the database after the first submission. Thanks


Solution

  • I guess I'll reply this myself, I made a very silly mistake and i found out that the apostrophes were causing the error. I ended using bindParam to solve that. You can also use addslashes() function for that.