E
E
Eugene2014-07-16 15:17:18
linux
Eugene, 2014-07-16 15:17:18

Why does MySQL display question marks?

Good afternoon.
For an hour now I have been trying to understand what is the problem that appeared after moving to a dedicated server.
The fact is that when adding data to the MySQL database through a website, question marks appear instead of Russian letters.
When connecting to the database, I do the following:
mysqli_set_charset($this->_db_connection, "UTF8");
In the file /etc/mysql/conf.d/utf8_charset.cnf the following:

[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
init-connect="SET NAMES utf8"

[client]
default-character-set=utf8

SHOW GLOBAL VARIABLES LIKE 'char%';
mysql> SHOW GLOBAL VARIABLES LIKE 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

And anyway, when adding data, questions appear in the database itself (checked through MySQL Workbench).
It's funny that when adding data through MySQL Workbench, everything is added correctly and displayed correctly on the website too.
What am I doing wrong?
Ubuntu 14.04
MySQL version: 5.5.37
PHP 5.5.9

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Petrikov, 2014-07-16
@Qwofer

First, create a database in utf-8 (if you need this encoding), then re-upload the dump.

D
Dmitry Entelis, 2014-07-16
@DmitriyEntelis

And the collation in the fields in the database/base itself is normal selected?
Look at what headers the site itself gives - maybe it's not UTF-8 all of a sudden?

Y
yischyk, 2019-05-29
@yischyk

when connecting with a database, write:
$connect = mysqli_connect('localhost', 'root', 'your_password', 'db_name');
then write the query
mysqli_set_charset($connect, 'utf8');
utf8 encoding can be replaced with cp1250, if it is set in your database
ps to see the database encoding, you need to select this database, and in the Structure look Comparison

A
almasvas, 2018-10-21
@almasvas

Fucking MySQL, same problem. And the base in UTF8 and POST passes in UTF8, but the procedure works with question marks .. already indicated both CHARACTER SET utf8 and collate utf8 in the procedure and still question marks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question