Answer the question
In order to leave comments, you need to log in
Why is encoded text coming from an AJAX POST request in PHP?
I send the request like this:
$.post("ajax.php",
{
act: "avatar",
persname: $("#persname").val()
},
onAjaxSuccess
);
htmlspecialchars($_POST['persname']);
Answer the question
In order to leave comments, you need to log in
Problem solved.
Locally, the database was created through phpmyadmin - and UTF-8 encoding was selected.
When transferred to the server, the database was created manually from the console, without explicitly specifying the base encoding, so the database was in latin encoding ...
Existing tables were imported into the created database, which were in the correct utf8_general_ci encoding.
Despite the fact that the tables were in the correct encoding, the encoding broke.
Maybe the encodings of the page and the script are different?
Did you know that when sending $.post all text is automatically encoded in UTF-8? Maybe this is the issue?
.For some reason, it seems to me that your PHP script encoding is incorrect. Standard UTF8.
try setting on hosting via htaccess parameter:
php_value default_charset UTF-8
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question