Cyrillic letters are posting as spec symbols in db.
here is my php code
<?php
header('Content-Type: text/html; charset=utf-8');
include("../connection.php");
$data = json_decode(file_get_contents("php://input"));
$address = "Коля";
$description = $data->description;
$alt = $data->lat;
$lon= $data->lng;
$q = "INSERT INTO pitches (address, description,alt,lon) VALUES (:address, :description,:alt,:lon)";
$query = $db->prepare($q);
$execute = $query->execute(array(
":address" => $address,
":description" => $description,
":alt"=>$alt,
":lon"=>$lon
));
echo mb_detect_encoding($description);
?>
Also I've added .htaccess file to root of my site with AddDefaultCharset UTF-8
Here are my screenshots from phpmyadmin:
I have utf8 encoding everywhere but still my php posts me data like this КолÑ. I've tried everything I knew but can't understand what's wrong.
echo mb_detect_encoding($description) shows me ANSII,
echo mb_detect_encoding($address) shows me UTF-8 Will be really thankful for help.
Have you tried mysql set charset?
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Change character set to utf8
mysqli_set_charset($con,"utf8");
mysqli_close($con);
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.