Cannot properly insert greek characters in mysql database

后端 未结 5 2070
一生所求
一生所求 2020-12-11 05:52

Our mysql database shows Î Î¿Î»Ï Î³Î»Ï…ÎºÏŒÏ in place of greek characters while sending data from an emulator to a mysql database. Other characters are left ok.

5条回答
  •  鱼传尺愫
    2020-12-11 06:32

    An excellent introduction about using UTF8 with PHP and Mysql can be found in this blog. The main points are:

    1. Set the database tables to UTF8
    2. In your php.ini set default_charset = "utf-8";
    3. After the connection is established you may have to run the following command/query: set names UTF-8;

    I guess you are missing point 3.

    In your PHP script, you should do something like this (untested):

    $handler = new PDO('mysql:host=localhost;dbname=database', 
      'username', 
      'password',
      array(PDO::MYSQL_ATTR_INIT_COMMAND => 
        'SET NAMES utf8;SET CHARACTER SET UTF8;'));
    

提交回复
热议问题