Error with characters in a html iframe

前端 未结 1 329
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-27 20:16

excuse my English I speak Spanish

I\'m trying to display multiple php and mysql registrations which will be shown inside an iframe.

the

相关标签:
1条回答
  • 2021-01-27 21:05

    If the problem is not in the files to display in the frame, may be the problem in the data. I always try to configure PHP, Apache and MySQL with UTF8. For this, I edit some configuration files.

    MySQL: /etc/my.cnf

    [client]
    default-character-set=utf8
    
    [mysqld]
    character-set-server=utf8
    init-connect='SET NAMES utf8'
    character-set-client=utf8
    character_set_results=utf8
    

    Then:

    sudo service mysql restart
    

    PHP: /etc/php.ini

    default_charset = "UTF-8"
    

    Apache: /etc/apache2/conf.d/charset

    AddDefaultCharset UTF-8
    

    Then:

    sudo service apache2 restart
    

    Another thing to consider when connecting to the database:

    ...
    $link = mysql_connect(SERVER, USER, PASSWORD);
    mysql_set_charset('utf8', $link);
    ...
    

    You can see all characters related variables using:

    SHOW VARIABLES LIKE 'c%';
    
    +--------------------------+----------------------------+
    | Variable_name            | Value                      |
    +--------------------------+----------------------------+
    | character_set_client     | utf8                       |
    | character_set_connection | utf8                       |
    | character_set_database   | utf8                       |
    | character_set_filesystem | binary                     |
    | character_set_results    | utf8                       |
    | character_set_server     | utf8                       |
    | character_set_system     | utf8                       |
    | character_sets_dir       | /usr/share/mysql/charsets/ |
    | collation_connection     | utf8_general_ci            |
    | collation_database       | utf8_general_ci            |
    | collation_server         | utf8_general_ci            |
    | completion_type          | NO_CHAIN                   |
    | concurrent_insert        | AUTO                       |
    | connect_timeout          | 10                         |
    +--------------------------+----------------------------+
    

    You must make sure that the page displayed in the iframe tag has also:

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

    I hope it helps somewhat.

    0 讨论(0)
提交回复
热议问题