nutballs

I have been having lots of issues with character encodings for some reason. I am still having a

regex

  problem, and was until just now, having a mysql storage issue.

I have the tables set to a charset of utf8 and colation of utf8-general-ci
You would think this would work, but oh no...
Chars still get stored as funky combos of extended characters. like "don’t" getting stored as "don’t".
apparently the problem comes from the connection. The connection actually needs to be UTF8. go figure...

so, all you need to do is add this right after your database connection in

PHP

 , but before you do anything of value with the DB.
mysql_query("SET NAMES `utf8` COLLATE `utf8_general_ci`"Applause

you can do this from some file settings or ini files, but, you may not have access to that stuff. I generally prefer to set stuff from runtime, since I may not know what environment my stuff might run under. A little loss of efficiency, for complete portability is my general rule.

I wanted to post this, because it drove me nuts, and someone else might benefit from the solution.

perkiset

Beauty NBs, thanks - I get troubles with that stuff occasionally as well but haven't taken the time to figger it out.  Applause

nutballs

to quote martha. "it's a good thing."

DangerMouse

The UTF-8 default character encoding thing will be the best part of

PHP

 6 I hope.

DM

nutballs

i think so as well. especially since I seem to be finding every single issue with UTF under mysql 5 and

php

 5 lol.

webguy332

Will the upgrade to

php

 6 be worth the headaches?

nutballs

probably not until after a few point releases. but for built in utf8, i might be an early adopter...


Perkiset's Place Home   Politics @ Perkiset's