Storing Chinese Characters in Mysql / Chinese Characters Not Working in MySQL

Recently transferring to another website, the chinese characters are not working already.

Googling the answer led me to this code, you can convert existing columns one by one, or else you can convert them all at once this way:

mysql> ALTER TABLE nameTable CONVERT TO CHARACTER SET utf8mb4, COLLATE utf8mb4_bin;

mysql> SHOW CREATE TABLE nameTable\G

CREATE TABLE `nameTable` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `version` bigint(20) DEFAULT NULL,
  `country` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `englishName` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  `chinesename` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin 

After running the code made it ok

Thank you for the web

Coffee Cup

Not Acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security [SOLVED]

Working on programming for so many years, it amazes me that i have really much to learn. This recent issue cropped up out of nowhere.

I decided to disable mod security , which is a bad idea honestly. But true enough, i found the culprit. It seems when you pass a get parameter with special characters, our websites seem to be on high alert against hack attack

<IfModule mod_security.c>
  SecFilterEngine Off
  SecFilterScanPOST Off
</IfModule>

What i was passing is the name of a client through get command. Yeah i know . It came out as link.php?name=M&M

I changed then parameter to a session id i had given before and it solved the issue. sigh. another lesson learned.

Coffee Cup

#1005 – Can’t create table ‘xxxxxx’ (errno: 150) [SOLVED]

If you are using xampp and you encounter this message during creation of a table, i have found that a lot of them pertain to the unit used to reference the field. If the master table used INT (11), when you reference it as a foreign key, you also need to use the same unit INT(11) as well.

In my case it was different. You see, i got this message because the table I used as a foreign key is the table ‘item’ whereas originally it was table ‘item_list’.

So just in case you encounter this one and still have problems, it might be the table name.

Learn and move forward

Coffee Cup