Answer the question
In order to leave comments, you need to log in
How to solve the encoding problem when transferring data between MySQL databases?
There is a Mysql database latin1_swedish_ci and each plate is utf8_unicode_ci. Using a PHP script, I take data from it and add it to another database. If, in a new database, put the same encoding or another one, the following comes to the database: ГДавный дизайнер How to solve the problem?
Answer the question
In order to leave comments, you need to log in
Try after establishing a connection with each database:
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
mysql_query("SET SESSION collation_connection = 'utf8_general_ci'");
Better yet, switch to PDO:
$database = new PDO('mysql:host=127.0.0.1;dbname=project', "user", "god", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question