The other day I ran into a stupid situation. We launched one web project, everything works, the code is written and supplemented, the databases are filled. Development goes on a test host, then the changes are uploaded to the server, the entire check is reduced to entering the site and the test of everything and everyone. Suddenly, it turns out that the letter “sh” is not displayed on the site, and instead of it there are two meaningless symbols.
The same story was with the letter "I". Immediately go to the database on the server and see ... solid "krakozyabry", instead of Cyrillic. But the Latin is written normally.
Of course, everyone thought about problems with encodings and of course it is. We take a closer look ... Table encoding is UTF-8, the encoding of the required columns is UTF-8, the encoding in the page headers is UTF-8, the encoding in the browser is UTF-8. And of course the intermediate link failed, the connection encoding is cp1251. And all just because they did not verify the identity of the settings of the test and working database server. A silly mistake, but the data in the database is already full and you need to somehow return them. Googling all that was possible, several interesting sql queries were found, methods with shamanism of encodings in dumps, with the help of a notepad, and one php script that, having worked out correctly, simply issued the same hieroglyphs. Something did not help, something just does not fit.
My solution is trivial, but I have not found such a thing on the open spaces of the network.
We write a small php script driving the desired tables into the desired format.
')
<?php define('BD_HOST','localhost'); define('BD_PASS','password'); define('BD_LOGIN','login');
That's all. The script did exactly what was needed and was written in a couple of minutes, so it may be surprising that the same can be made more flexible and optimized, but it would also be nice to fasten the OOP.
I hope that this script is useful to anyone.
Thanks for attention.
UPD:
Thanks to
edogs for the hint, removed extra queries to the database.