MySql / php utf8似乎无法正常工作

So I have a table that is 'utf8_general_ci' with the same fields.

I couldn't get any utf8 characters into it, they all showed as '????' , then I changed table to 'MyISAM' and now I can insert utf8 data from PhpMyAdmin (first time something like this happens).

But it still doesn't work from PHP side. When I insert 'āāā' it shows as '???', but the weird part is if I insert 'žžžēēē' it show as 'žžž???' so some utf8 characters work? PHP file is UTF-8

CREATE TABLE IF NOT EXISTS `company` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci AUTO_INCREMENT=5 ;

$dbConnection = mysql_connect("localhost","*****","*****");
mysql_query("SET NAMES 'utf8'", $dbConnection);
mysql_query("SET CHARACTER SET 'utf8'", $dbConnection);
mysql_select_db('cherrysystem', $dbConnection);
mysql_query("INSERT INTO `company` (`title`) VALUES ('āāčč')",$dbConnection);

RESOLVED

Ok, so problem in my case was that I had to set MySql ini file to use utf8. By default it was something else, I'm using Wamp server and it have always worked without extra configuring, but not in this case.

 character-set-server=utf8
 collation-server=utf8_general_ci

Obviously something is not 'Unicode' in the way you handle the data.

Here are my top 7 usual suspects :

  • PHP file containing the code is not UTF-8 itself
  • Database connection must conform to Unicode (SET NAMES 'utf8')
  • Inserted data must be utf8 encoded if importing from a non unicode source e.g
  • Check tables and the columns used to store data
  • HTML file used to display the data is not UTF (same as point 1)
  • HTML charset declared in meta tags must be utf-8 also
  • ... no point 7 (maybe in the comments)

Hope this helps!