Search code examples
htmlcharactermeta

Encoding sql characters don't work


i'm using phpmyadmin, i had some special character in my bd, like 'é'.
but when i try to print in on my website, black cube with a white '?' apear.
I tried theses lines :
- <meta http-equiv= "content-type" content= "text/html; charset=iso-8859-1" >
- <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" />
- <meta charset="UTF-8">

And nothing change. i'm using notpadd ++, an idea?


Solution

  • You should check that you have selected Encode UTF-8 Without BOM - if you have selected encode in ANSI you should select all your code (ctrl + a) and then hit "convert to UTF-8 without BOM". Ensure you save it afterwards. Recheck that it successfully changed and then retry.

    enter image description here

    Update:

    Ensure your tables coallation is set to utf8_unicode_ci, aswell as your text or character colums.

    together with

     <meta charset="utf-8">
    

    this should work. Otherwise you should test if the problem only appears with data read from your database, or also with hardcoded special characters.

    If only your database strings cause problems i suggest the following link to set your charset (if you use mysqli) http://php.net/manual/de/mysqli.set-charset.php