I have some forms, that insert some data into a MySQL database, and for some reason the characters get double utf-8 encoded. You don't see it on the front-end of my website, but in the back-end you do, if i look at the data from phpmyadmin, it's double encoded.
Also, to display data entered from phpmyadmin i have to utf8_encode
it.
If i use uft8_decode()
on my data before i put it into my database, it works, but then i'd have to use utf8_encode()
again to display my data properly, and i would like to find a better solution that re-writing most of my code.
The characters i'm dealing with is the danish æ, ø and å characters.
I have every setting i can find in php.ini set to utf-8, every thing i can find in phpmyadmin to utf8, html meta tag set to utf-8, and still i have this error to deal with.
So my question is, does anyone know why this happens, or how i could fix it?..
Update: After running the mysql code Jako suggested, the data is properly encoded in the back-end of the database when it comes from the front-end, but i still need to run utf8_encode()
to display the data properly on the front-end, any ideas?..
Update 2: Again, after running the code from the answer to this question i still had problems, the encoding was now on and off utf8, and i suspect phpmyadmin for resetting the encoding somehow. I found a new way of doing things, and it works flawlessly, described in my answer below...