Search code examples
phpmysqlutf-8collate

Create TABLE in PHP using


tables in my database where are some unusual letters from czech alphabet like ěščřžýáíé ignore my query. I think it could be solve via CHARACTER SET utf8 COLLATE utf8_czech_ci, but it looks like i dont know how to use it. Iam trying this code, but for sure, there is some problem:

        mysql_query("CREATE TABLE `".$userreg."` CHARACTER SET utf8 COLLATE utf8_czech_ci(
        id INT NOT NULL AUTO_INCREMENT, 
        PRIMARY KEY(id),
        title VARCHAR(30), 
        rating_estimate INT)")
        or die(mysql_error());

I have to create table in PHP code, because it depends on another variables. Browser shows "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), title VARCHAR(30), ' at line 2".

Any idea how to fix?


Solution

  • CHARACTER SET utf8 COLLATE utf8_czech_ci
    

    needs to be at the end of the CREATE statement after the closing ')'