The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

problem encoding mysql 5.6

Discussion in 'Database Discussions' started by FirasBenk, Mar 19, 2015.

  1. FirasBenk

    FirasBenk Member

    Joined:
    Mar 19, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    TUNIS
    cPanel Access Level:
    Reseller Owner
    Hello,

    I can't insert into my data base a special characters, for exemple when I insert the word "hôtel" I have in my base "h?tel". Only latin1 is supported but impossible with UTF8.

    This is my configuration:
    • Version du serveur : 5.6.21 - MySQL Community Server (GPL)
    • Jeu de caractères du serveur : UTF-8 Unicode (utf8)
    • cpsrvd 11.44.3.1
    • Version du client de base de données : libmysql - 5.1.73
    • Extension PHP : mysqli
    • PhpMyadmin: 4.1.8
    I have insert in my code, after INSERT INTO:
    • mysql_set_charset('utf8mb4');
    In my MySQL configuration file (/etc/my.cnf):
    • [client]
      default-character-set = utf8mb4

      [mysql]
      default-character-set = utf8mb4

      [mysqld]
      character-set-client-handshake = FALSE
      character-set-server = utf8mb4
      collation-server = utf8mb4_unicode_ci
    My data base is in utf8mb4_unicode_ci
     
  2. FirasBenk

    FirasBenk Member

    Joined:
    Mar 19, 2015
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    TUNIS
    cPanel Access Level:
    Reseller Owner
    Hello,

    I have found the probleme, it's in my php, not with my data base:

    when I try:
    $sql = 'INSERT INTO table VALUES ("accentué")';
    => it's ok

    but when I try:
    mysql_set_charset('utf8');
    $test=utf8_decode( 'Texte accentué' );
    echo $test;
    $sql = 'INSERT INTO firas VALUES ("'.$test.'")';
    => I have in my echo: accentu?
    and in my data base: accentu?

    How Can I force php to work with UTF8?
    I have add this in httpd.conf:
    AddDefaultCharset utf-8
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You can change the "default_charset" value in /usr/local/lib/php.ini via:

    "WHM Home » Service Configuration » PHP Configuration Editor » Advanced Mode"

    Thank you.
     
Loading...

Share This Page