I am not sure if this is because of jquery, mysql or php
I have a basic AJAX call:
$(document).on("click", "#save-edit", function(){
var id = $(this).closest("div.answer-section").attr("data-id");
$.ajax({
type: "post",
data: {
id: id,
answer: $("#edit-box").val()
},
url: "/process/edit",
dataType: "json",
success: function(data){
// display the data
}
});
});
and a basic SQL query:
$sql = $pdo->prepare("update answers set answer = :answer where answer_id = :aid");
$sql->bindParam("answer", $_POST["answer"], PDO::PARAM_STR);
$sql->bindParam("aid", $_POST["id"], PDO::PARAM_INT);
$sql->execute();
The problem I am having is, it saves characters like this: é é
in the database as this é é
then displays é é
on the page, so what is causing this, the JQuery, or the MySQL or the PHP? How can I fix it?