0

I'm at begginner level of mysql, doing transition from access to mysql got a very simple routine running, inserting some data from simple phpform into localhost base. i ran into a problem with some slavic characters like čšž as they don't display right

  • got mysql base set to utf-8 encoding and if i input directly it works ok

  • got all meta data set to

  • got this after connection

    mysql_query("SET NAMES ''utf8'' COLLATE ''utf8_slovenian_ci''"); mysql_query("SET CHARACTER SET ''utf8_slovenian_ci'';");

Still get gibberish like this Äćžđšp or this Å¡pela

Any ideas

1 Answer 1

1

When dealing with UTF-8, you have to make sure that everything is setup to use UTF-8.

You correctly enabled UTF-8 in the database (make sure that also the column is set to use UTF-8; in my opinion, it's best to use utf8_bin - faster at sorting and less country-specific).
However, what about the web server?

Make sure your pages are using UTF-8, with the correct meta tag:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Additionally, it wouldn't hurt to set the web server to use UTF-8 too: see this question, for example.

Eventually, remember that PHP 5 per se does NOT work with Unicode. As such, you must be extremely careful when using string functions, such as strencode, substr, etc. Some string functions have support for Unicode (see their documentation). In other cases, you may use mbstring functions.

Sign up to request clarification or add additional context in comments.

2 Comments

tx, had all tha enabled, i guess. I changed mysql_query line to mysql_query("set names 'utf8'"); and it solved my problems
this line in place of previous query solved my problems

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.