Database MySQL version 4.1 and the Czech
The database on the server with the version of the MySQL version 4.1 is established without the set default character set (i.e.. Latin1).
For the correct operation of the Czech characters it is necessary that the user has set the character set in which the database is encoded in. It shall carry out, for example. through the phpMyAdmin SQL command:
ALTER DATABASE database_nameDEFAULT CHARACTER SET cp1250
DEFAULT COLLATE cp1250_czech_cs;
The following user database database_name set default encoding to windows-1252 (cp1250) and grading of the Czech, which distinguishes the size of pímen.
Another example is possible to set the character set UTF-8 and the Czech sorting, case-insensitive (dopručujeme all):
ALTER DATABASE database_name
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_czech_ci;
If vytvořítme then the following table with two columns ID and value:
CREATE TABLE cz_test
(ID INT NOT NULL AUTO_INCREMENT,
value VARCHAR (255) COLLATE utf8_czech_ci CHARACTER SET utf8, PRIMARY KEY (ID)
) TYPE = MYISAM CHARACTER SET utf8 COLLATE utf8_czech_ci;
the problem is not to insert the Czech characters correctly and works and classification of characters such as "ch".
In the further examination of the manual page you will find that the character set to be transmitted to the server can be modified through the HUNDRED NAMES-see http://dev.mysql.com/doc/mysql/en/set-option.html
For output in the appropriate encoding (e.g., windows-1250) on a Web presentation you need to specify the connection after the normal command MySQL_Query ("SET NAMES ' cp1250 '");This part of the code might look like for the connection to the database:
$link = MySQL_Connect("adresa_databazoveho_serveru", "nazev_uzivatele", "heslo")
or die("Nelze se připojit"); //připojení k serveru
MySQL_Select_DB("nazev_databaze") or die("Nelze vybrat databazi"); //výběr databáze
MySQL_Query("SET NAMES 'cp1250'"); //překóduje DB do windows-1250
// .....další příkazy a dotazy na databázi
MySQL_Close($link); //ukončení spojení
Under the bounce in the top of the page are two examples for the encoding windows-1252 and utf-8.
The man pages (Chapter 10. Character Set Support): http://dev.mysql.com/doc/mysql/en/charset.html