Search code examples
phpencodingutf-8smartphone

Database content shows utf-8 encoded caracters but the ones written in php are not shown


I have php website, my database content is encoded properly, but content i typed in html doesn't show utf-8 encoding caracters, when I am accessing site through my smartphone. I did put

    header('Content-type: text/html; charset=utf-8');

and

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

in my head tag, but it still doesn't work. Does anyone know what could be wrong? Thanks.


Solution

  • Please try to execute this queries before selection of data:

    SET NAMES UTF8; 
    SET CHARACTER SET 'utf8';
    SET SESSION collation_connection = 'utf8_general_ci';
    

    It will set the fetched data encoding to UTF-8.

    Also, did you store your data or your script source code with BOM? Try to remove it using some text editor, i.e. Notepad++