Hello, there was a problem, they said to screw the payment gateway free-kassa and now I have a huge problem with writing to the database.

We are sent a request:

MERCHANT_ORDER_ID = 1000 + +% EF% EE% E4% EF% E8% F1% F7% E8% EA% EE% E2 +% ED% E0 +% EB% E8% F7% ED% F3% FE +% F1% F2% F0% E0%ED%E8%F6%F3+%28VK%29&P_PHONE=&P_EMAIL=test%40yandex.ua&CUR_ID=45&AMOUNT=3&MERCHANT_ID=38053&SIGN=5bc4c57fc7769ed8b2a1c75kd/an/x75/1 of 5

I write it separately in a file, and separately in a DB. So, everything is written in the file normally, but the information in Cyrillic is not written in the database. And the funny thing is, I have already separately recorded the SQL query that PHP produces and manually generated it in the PMA and everything was recorded perfectly, but through mysql_query, nothing at all, instead of Cyrillic, nothing.

screenshot bd

I tried to change the encoding of windows-1251 DB (for even in it we transfer data to the gateway, but everything is still written in the file) and in no way, the same result.

UPD: Support answer: "There was support7A, yes) they did not decide to write everything in Latin." Transformation to base64 also did not help because of the encoding (see comments). Perhaps there will be more suggestions?

  • What do you want to do with this record from the database? - Visman
  • @Visman, display in a small socket and that's it. In the future, only a status column will be affected by editing. - Felix
  • Support answer: "There was, yes, yes) they did not decide to write everything in the Latin alphabet. Use a regular schedule or is there some kind of function? - Felix
  • one
    Maybe it should then convert to base64 before recording, so that the encodings do not suffer, and when output back to the original text to decode? - Visman
  • one
    No there you have any bebberdy. Here is sandbox.onlinephpfunctions.com/code/… everything is readable. - Visman

1 answer 1

If the same request in PMA works as it should, and from the php script it has problems with Cyrillic, then the server does not understand what encoding you are working with. PMA indicates the encoding, but you do not!
You need to complete

SET NAMES ваша_кодировка_страниц 

immediately after the connection. The coding of your client is mentioned here, and not the coding of the data in the database (they may be the same or the same). Or use similar mysqli / PDO calls.

  • one
    Right, you are right! I had set names, but I already safely forgot that I used it and there utf8 stands, because I connected the file separately and it was not there before my eyes. Thank you, otherwise we have not made any crutches here :) - Felix