O
O
Orbite2018-07-11 06:54:45
Perl
Orbite, 2018-07-11 06:54:45

The coding at an insertion in a DB from PERL spoils. How to decide?

When UPDATE from the perl script spoils the text encoding, and incomprehensible characters are entered into the database instead of the Russian text. Tell me how to solve this problem? I am attaching a code example. koi8r script encoding, koi8r_general_ci table encoding

$name_bank = 'Имя банка';
        
                $sql="UPDATE arm_money SET number_bank_acc='$number_bank_account', name_bank='$name_bank', related_pay_info='$related_pay_info' WHERE LinkID= ".$m;
                $sth= $dbh->prepare($sql) or error('CANNOT_PREPARE', 'Не могу подготовить запрос '.(DEBUG ? $sql.':<br> '.$DBI::errstr : ''));     
                $sth->execute() or error('CANNOT_EXECUTE', 'Не могу выполнить запрос '.(DEBUG ? $sql.':<br> '.$DBI::errstr : ''));

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
krypt3r, 2018-07-11
@Orbite

SET NAMES 'koi8-r'

B
BloodVIRUS, 2018-07-11
@BloodVIRUS

Make base, table, connection encoding utf8_general_ci, and everything will work.

O
Orbite, 2018-07-11
@Orbite

Thank you all guys in particular krypt3r and ThunderCat .
I did it a little differently, in addition to the database, I also recorded this data in an excel book, pulled it out of excel, did $dbh->do("SET NAMES 'utf8'");
$dbh->do("SET character_set_connection = 'utf8'");
and everything is displayed normally!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question