MySQL character problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
LDusan
Forum Commoner
Posts: 45
Joined: Sun Mar 08, 2009 5:03 am
Location: Belgrade, Serbia

MySQL character problem

Post by LDusan »

Hi all, I am really having a problem with this one.

I am using utf_8 encoding and the problem is that when i enter some of the characters from serbian language (like ŠĐĆĆ..) in any varchar field in any MySQL table (using phpmyadmin), the page just doesn't recognize these and doesn't display them right on page when I do some query.

A friend of mine told me to use form for data entry, so I did that and it works fine, but now the characters in the database are not ok when I view it with phpmyadmin, so it's unusable if I want to, let's say send an email containing the data.

Is there any solution to this?

Any kind of help is greatly appreciated.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: MySQL character problem

Post by Eran »

You need to force UTF encoding for the database connection. Make sure the following two lines are in your mysql configuration file:

Code: Select all

default-character-set=utf8
skip-character-set-client-handshake
If you don't have access to it, you should run the following queries before communicating with the database:

Code: Select all

SET CHARACTER SET 'utf8'
SET NAMES 'utf8'
LDusan
Forum Commoner
Posts: 45
Joined: Sun Mar 08, 2009 5:03 am
Location: Belgrade, Serbia

Re: MySQL character problem

Post by LDusan »

Thanks for the quick reply, that was GREAT!!! Saved me a lot of time, thanks a lot!!!
Post Reply