Martin Kovac 0 Newbie Poster

Hi,
I'm new in using MySQL database and have problem with character encoding.
Database was created by this query:

CREATE DATABASE 'dbname' CHARACTER SET utf8 COLLATE utf8_general_ci;

Then I've create table using this query:

CREATE TABLE IF NOT EXISTS 'tblname' ( ... ) CHARACTER SET utf8 COLLATE utf8_general_ci;

AFTER query: STATUS; I got this result:
Connection id: 442
Current database: dbname
Current user: user@localhost
SSL: Not in use
Current pager: /usr/bin/less
Using outfile: ''
Using delimiter: ;
Server version: 5.0.70-log Gentoo Linux mysql-5.0.70-r1
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 66 days 2 hours 32 min 7 sec

And after this query: SHOW VARIABLES LIKE 'char%'; I got result:
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

And last this query: SHOW TABLE STATUS; +-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| users | MyISAM | 10 | Dynamic | 4 | 22 | 88 | 281474976710655 | 2048 | 0 | 5 | 2009-03-19 12:11:41 | 2009-03-19 12:11:41 | NULL | utf8_general_ci | NULL | | |
+-------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+

So I think that everything is OK and I can insert some data to my database so I execute this query:

INSERT INTO tblname (fullName) VALUES ('myFullName');
INSERT INTO tblname (fullName) VALUES ('mySecondFullNamewithľščťžýáíé...');

AFTER query: SELECT * FROM tblname I got result:
+----+----------------------+
| id | fullName |
+----+----------------------+
| 1 | myFullName |
| 2 | mySecondFullNamewith |
+----+----------------------+
2 rows in set (0.00 sec)

So my data was not correctly inserted into my database. The problem is that characters like ľ š č ť ž ý á í é ú etc. was not inserted.

Where is the problem?

When I retrieve data from MySQL database by PHP is shows me the same result without characters show below.
My server version: 5.0.70-log Gentoo Linux mysql-5.0.70-r1

Maybe can help that I was working on MySQL database using PuTTY release 0.57 on WINDOWS XP PROFESSIONAL, version 2002, Service Pack 3, ENG

Thanks everyone who can help me solve this problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.