S
S
Sergey Valitov2015-11-29 09:37:16
PHP
Sergey Valitov, 2015-11-29 09:37:16

From in php to mysql saves krakozyabry?

Hello! Faced such problem - at INSERTe in a DB values ​​are saved there in krakozyabra, a kind ÐÑ?Ñ?кÑ?Ñ?Ñ?н. The encoding on the site is UTF-8 by default. I set utf8_general_ci in the database for the table.
When executed , the following is displayed: character_set_client utf8mb4 character_set_connection utf8mb4 character_set_database utf8 character_set_filesystem binary character_set_results utf8mb4 character_set_server latin1 character_set_system utf8 character_sets_dir /usr/share/mysql/charsets/ .. SHOW VARIABLES LIKE 'char%'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Hinex, 2015-11-29
@HiNeX

$mysqli->set_charset("utf8")
have you tried?

R
Robot, 2015-11-29
@iam_not_a_robot

Connection to PDO:

$charset = 'utf8';
    $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
    $opt = array(
        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
    );
    $pdo = new PDO($dsn, $user, $pass, $opt);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question