A
A
Armand M2015-10-08 13:27:31
PHP
Armand M, 2015-10-08 13:27:31

How to fix encoding?

I deduce record from a DB, such question marks are deduced here. Exactly question marks, not scribbles as with incorrect encoding. Tell me what to do?
badb4e6b46fd4009aaf42d63d4c85a98.PNG

Answer the question

In order to leave comments, you need to log in

6 answer(s)
I
Ivanq, 2015-10-08
@Ivanq

Is everything okay with the base?
If not, it's most likely the script.

O
Omich, 2015-10-08
@omichkun

Try
pasting after

mysql_query('SET NAMES utf8');          
mysql_query('SET CHARACTER SET utf8');  
mysql_query('SET COLLATION_CONNECTION="utf8_general_ci"');

And check that you have utf8_general_ci encoded data in your database.

L
LittleFatNinja, 2015-10-08
@LittleFatNinja

<?php 

$db = mysql_connect("localhost","arman","kiker555");
mysql_select_db("firstbd",$db);

mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $db);
$result = mysql_query("SELECT * FROM firma",$db);
$myrow = mysql_fetch_array($result);

echo $myrow["name"];

?>

M
Max, 2015-10-08
@MaxDukov

1. forget you already about mysql_connect. only mysqli
2. what is the encoding in html? Please provide the page code in full.

I
Igor Vorotnev, 2015-10-08
@HeadOnFire

Question marks are also an encoding problem, not always scribbles. Depends on what is the source and what is the final encoding. The final is most likely UTF, which means the original, most likely, cp-1251.

O
Orzubek Rakhimov, 2015-10-08
@orzubek

Maybe this?
echo iconv("windows-1251", "UTF-8", $db); //if it doesn't work, then here
//echo iconv("UTF-8", "windows-1251", $db);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question