Hello. Task: parse the information from the site and save it to our database.
I get the information I need and display on the screen, everything is as it should. But there was a problem with the recording of information in the database, namely the recording of Russian characters .
In the php file, the parser wrote:
header('Content-Type: text/html; charset=Windows-1251'); mb_internal_encoding('Windows-1251'); mb_http_output('Windows-1251'); mb_http_input('Windows-1251'); The parser works on simple_html_dom.php
The code itself:
$html = file_get_html('http://www.favorit-auto.ru/producers/?page=1'); $a_links = $html->find('#producers_content .vendors li a'); foreach ($a_links as & $value) { $html2 = file_get_html('http://www.favorit-auto.ru'.$value->href.''); $a_links2 = $html2->find('.vendor_text'); $prod = $value->plaintext = preg_replace('/\(.*?\)/', '', $value->plaintext); $prod1 = substr($prod, 0, -1); $url = translit($prod1); $opis = $a_links2[0]->plaintext; /* Добавляем производителя */ mysql_query("INSERT INTO `producers` (`url`, `name`, `content`) values('$url', '$prod1', '$opis')"); } What ultimately happens: Recording goes to the database, but if we receive a Russian text, it does not write to the database, and the Russian text is displayed well on the screen.
The Comparison parameter for the text field in the database is utf8_general_ci . I tried to install cp1250_bin - now it turns out that the text in the database is recorded only in English. characters, and Russian writes like " ??? ??? ???????????? "
How do I solve this problem? How to choose the desired encoding? I would be very grateful for the help!