The $_POST['reply'] variable contains html tags like <p>text goes here</p> but I can not insert it into the database. For the reply I use the TinyMCE and when I do not use it (the input as no tags) like text goes here then it is inserted correctly.
What am I missing here?
try {
    $db = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $db->prepare("INSERT INTO replies(article_id, comment) VALUES (:article_id, :comment)");
    $stmt->bindParam(':article_id', $article_id, PDO::PARAM_INT);
    $stmt->bindParam(':comment', $_POST['reply'], PDO::PARAM_STR);
    if($stmt->execute()) {
      echo 'success';  
    }
    $db = null;
} catch(PDOException $e) {
    trigger_error('Error occured while trying to insert into the DB:' . $e->getMessage(), E_USER_ERROR);
}
Here is the form code:
<form class="comment-form">
    <div class="form-input">
        <input type="hidden" name="post_id" value="<?= $row['id']; ?>" />
    </div>
    <div class="form-input">
        <textarea name="reply" id="elm1" rows="8"  placeholder="Your comment here" ></textarea>
    </div>
    <div class="form-input">
        <input type="Submit" class="btn btn-primary" id="submit" value="SEND" />
    </div>
</form>
<script type="text/javascript">
    $(function(){
        $(".comment-form").submit(function(event){
            event.preventDefault();
            $("#results")
                .show();
            $.post('add-it.php', $(".comment-form").serialize(), function(data) {
                $('#submit')
                    .hide();
                $('#results')
                    .html(data)
                    .fadeIn('slow');
            });
        });
    });
</script>
 
     
     
     
     
     
     
    
here goes text
` but it is not inserted. I have tried with no html tags, and it was saved. – EnexoOnoma Apr 06 '15 at 13:49` tags and post it to the php file, have a look at http://api.jquery.com/jquery.ajax/
– TheSk8rJesus Apr 06 '15 at 13:57