Reputation: 29
I'm having some errors in my MySQL with accents, all my files are in UTF-8.
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
But still not work, it just work if I place this after the MySQL Connection:
mysqli_query($conn,'SET character_set_results=utf8');
I have multiples functions that starts a new connection, so need to add for every one, its a problem.
My database are all in UTF-8 format.
Upvotes: 1
Views: 154
Reputation: 4389
After your mysqli_connect
line use mysqli_set_charset($conn,"utf8");
and it will set to to every of yours connection.
Upvotes: 2
Reputation: 3
try mysqli_set_charset($conn,'utf8')
$conn = mysqli_connect("host","username","password") or
die(mysqli_error($conn));
mysqli_set_charset($conn,'utf8');
mysqli_select_db($conn,'databasename') or die("cannot select DB");
Upvotes: 0