Quantcast
Viewing latest article 14
Browse Latest Browse All 757

Databases • How to correctly insert non-ascii characters in a MySQL database

Is there any possibility in this universe to insert non-ascii data correctly into a field in a MySQL database?

If I have a table mytable in "myDB" with a field "content" The field is set to utf8mb4_general_ci and try the following code:

CODE:

   put revOpenDatabase("mysql", "localhost","MyDB", "myUser", "mypassword") into tDBid   put "How can I insert ÅÄÖ correctly??" into tStr   put "INSERT into mytable (content) VALUES (:1)" into tSQL   revExecuteSQL tDBid, tSQL, "tStr"   revCloseDatabase tDBid
The data will not show up correctly in the database (when inspecting via mysql or phpmyadmin or any other database tool)
I think I have tried every permutation of textEncode or textDecode, like
put textEncode(tStr, "uff-8") into tStr
before calling revExecuteSQL but whatever combination I try the data in the database is NOT correct.

Any suggestions!

Statistics: Posted by hliljegren — Mon Mar 03, 2025 10:37 pm



Viewing latest article 14
Browse Latest Browse All 757

Trending Articles