Olda Stiller
Olda Stiller

Reputation: 65

CREATE MySQL TABLE in PHP with "utf8_unicode_ci"

I need to make a table in php, but i have to set up a "utf8_unicode_ci" coding. Iam using this code:

        mysql_query("CREATE TABLE `".$userreg."`(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        title VARCHAR(30), 
        rating_estimate INT NOT NULL) DEFAULT CHARSET=utf8")

but it builds "utf8_general_ci" table. Any advice how to create table in php with unicode coding? thx.

Upvotes: 3

Views: 9439

Answers (3)

mamal
mamal

Reputation: 2006

add this part after column set :

DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 

in your case :

"CREATE TABLE `".$userreg."`(
id INT NOT NULL AUTO_INCREMENT, 
PRIMARY KEY(id),
title VARCHAR(30), 
rating_estimate INT NOT NULL) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci "

Upvotes: 1

Deror
Deror

Reputation: 51

try it:

CREATE TABLE t (c CHAR(20) CHARACTER SET utf8 COLLATE utf8_bin);

Upvotes: 0

Hartmut Holzgraefe
Hartmut Holzgraefe

Reputation: 2765

Add COLLATE=utf8_unicode_ci after the CHARSET=utf8 option

Upvotes: 6

Related Questions