I use the following statement on every PHP page to set the connection to Unicode:
mysql_query ('SET NAMES utf8');
Is there a way I can skip this? By setting something on the server? I have a VPS so I should be able to access anything.
I supposed the real question is: do I need to? Will it speed things up I skip this statement for every single HTML page that is delivered?
you can modify mysql config(my.cnf)
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
There's no harm and effectively zero performance impact by running that command whenever you start a new connection.
If you wish to change the server configuration, here is the appropriate manual page on setting the connection character set defaults. You'll want to read the rest of the sections on defaults as well.
Why don't you just include a config file in every page, that contains all things related to creating a db connection?
This line is nesseccary, because you can really mess up data encoding in the db (been there, done that :))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With