Reputation: 41
I will try to be quick and easy to understand it. I'm having a problem with my project in PHP which I can't do anything to fix it, I have a instance of CKEditor in my website.
This is the config and the instance:
<script src="assets/ckeditor/ckeditor.js" charset="UTF-8"></script>
<textarea class="ckeditor" name="editor1" id="editor" rows="10" cols="80" required value="<?php if($error) echo $profdesc; ?> ">
<?php echo $profdesc; ?>
</textarea>
<script>
CKEDITOR.replace('editor1', {
contentsCss: "assets/ckeditor/test.css",
uiColor: '#428bca',
extraPlugins: 'wordcount,lineheight,colorbutton,smiley',
wordcount: {
showWordCount: true,
showParagraphs: false,
showCharCount: true,
maxCharCount: 3000,
paragraphsCountGreaterThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationparagraphs").css("background-color", "crimson").css("color", "white").text(currentLength + "/" + maxLength + " - paragraphs").show();
},
wordCountGreaterThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationword").css("background-color", "crimson").css("color", "white").text(currentLength + "/" + maxLength + " - word").show();
},
charCountGreaterThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationchar").css("background-color", "crimson").css("color", "white").text(currentLength + "/" + maxLength + " - char").show();
},
charCountLessThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationchar").css("background-color", "white").css("color", "black").hide();
},
paragraphsCountLessThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationparagraphs").css("background-color", "white").css("color", "black").hide();
},
wordCountLessThanMaxLengthEvent: function (currentLength, maxLength) {
$("#informationword").css("background-color", "white").css("color", "black").hide();
}
}
});
</script>
Everything works fine.. until I update the "description" with this editor, I have all my tables and mysql to UTF-8, or at least I think I have it. It could be a problem with the UPDATE SQL, here is the rest of the code. In this case I'm trying to save "Olá" in the DB.
if(mysqli_query($con, "UPDATE users SET username='" . $name1 .
"',description='" . $descr . "',gender='" . $gender .
"',location='" . $location . "',ocupation='" . $ocupation .
"' WHERE user_id = '" . $_SESSION['usr_id'] . "'"))
Upvotes: 0
Views: 1130
Reputation: 41
I managed to fix it! All I had to do was to put a:
mysqli_set_charset( $con, 'utf8');
before the:
if(mysqli_query($con, "UPDATE users SET username='" . $name1 . "',description='" . $descr . "',gender='" . $gender . "',location='" . $location . "',ocupation='" . $ocupation . "' WHERE user_id = '" . $_SESSION['usr_id'] . "'")) {
And the result was: "Olá"
Upvotes: 2