Answer the question
In order to leave comments, you need to log in
Why do I get ???? mesto krakozyabr?
I wrote a simple script to display data from a table:
<?php
// Подключение к базе: где $hostname - сервер, $username - имя юзера БД,
// $password - пароль юзера, $basename - имя базы с которой мы будем работать
$hostname = 'localhost';
$username = 'root';
$passwordname = 'root';
$basename = 'codebooks';
$conn = new mysqli($hostname, $username, $passwordname, $basename) or die ('Невозможно открыть базу');
// Формируем запрос из таблицы с именем blog
$sql = "SELECT * FROM `books`";
$result = $conn->query($sql);
// В цикле перебираем все записи таблицы и выводим их
while ($row = $result->fetch_assoc())
{
// Оператором echo выводим на экран поля таблицы name_blog и text_blog
echo 'Название блога: '.$row['description'];
echo 'Текст блога: '.$row['title'];
}
?>
Answer the question
In order to leave comments, you need to log in
set names - the solution is wrong, which even deserves a separate page in the manual: php.net/manual/en/mysqlinfo.concepts.charset.php
The solution is correct:$mysqli->set_charset('utf8');
I always knew:
- if you see the "text", then everything is fine;
- if you see "krakozyabry", then you will have to spend time solving the problem;
- if you see "????????????", then the encoding came full f*ck :)
If in essence. Try playing with iconv and mb_detect_encoding .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question