Strange hieroglyphics show when insert values in a MySql DB

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
psicloone
Forum Newbie
Posts: 5
Joined: Mon Jun 15, 2009 9:13 am

Strange hieroglyphics show when insert values in a MySql DB

Post by psicloone »

Hi,
I`m making a bulgarian language site and when a user submit text in a form with bulgarian characters to the database it shows in hieroglyphics.

When I echo the submitted text from the form - there are no problems - everything is shown correctly on the page.

Only the databases are problematic...

Im using meta tag with charset "windows-1251".

Any suggestions what to do about that?
waqas_punjabian
Forum Commoner
Posts: 67
Joined: Wed Aug 10, 2005 9:53 am

Re: Strange hieroglyphics show when insert values in a MySql DB

Post by waqas_punjabian »

What is the Collation of your databse tables and the field where you are saving those characters?

I think you should use "utf8_unicode_ci" for both of them. This will allow you to enter characters based on Unicode. (I suppose Bulgarian language characters are supported in UTF8) try it though.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Strange hieroglyphics show when insert values in a MySql DB

Post by Apollo »

psicloone wrote:Im using meta tag with charset "windows-1251".
That's in the HTML you generate, but your database probably contains/outputs something else.

Using ansi, even if you use it everywhere consistently, is really asking for problems sooner or later. For example, what happens if someone who was born in Sweden but now lives in Bulgaria and uses your site, and wants to fill in his name "Ånders Gustävsøn"? Can't express that in windows-1251 ansi.

Just use utf-8 everywhere (using utf8_unicode_ci collation for the SQL part) and you'll be safe.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: Strange hieroglyphics show when insert values in a MySql DB

Post by Apollo »

waqas_punjabian wrote:(I suppose Bulgarian language characters are supported in UTF8)
Certainly, Bulgarian uses Cyrillic characters, just like Russian and several other East-European languages.
Utf-8 is just an encoding for unicode, and unicode supports pretty much all reasonable characters used on planet earth (including Klingon :)).
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Strange hieroglyphics show when insert values in a MySql DB

Post by VladSun »

Apollo wrote:Just use utf-8 everywhere (using utf8_unicode_ci collation for the SQL part) and you'll be safe.
++

;)

Don't use cp-1251
There are 10 types of people in this world, those who understand binary and those who don't
psicloone
Forum Newbie
Posts: 5
Joined: Mon Jun 15, 2009 9:13 am

Re: Strange hieroglyphics show when insert values in a MySql DB

Post by psicloone »

Thanks for the help!

I used windows-1251 as meta tag, also my notepad was wrongly encoded, and the colation should had been utf8...
Post Reply