Page 1 of 1

Problem displaying database query result in UTF8

PostPosted: 20. October 2006 17:02
by Tiansen
I have configured Apache, PHP, MySQL to always use UTF8. I also have my data in MySQL encoded as UTF8 (phpMyAdmin displays it correctly). But when I import this data with PHP, I get data encoded in ISO-8859-1. So I see "?" instead of special characters. How is this possible? Have I forgot something?

Thank you very much for your help!

PostPosted: 20. October 2006 20:40
by Izzy
Which php.ini file did you configure?

Is this the section in the php.ini file you configured?
Code: Select all
; As of 4.0b4, PHP always outputs a character encoding by default in
; the Content-type: header.  To disable sending of the charset, simply
; set it to be empty.
;
; PHP's built-in default is text/html
default_mimetype = "text/html"
;default_charset = "iso-8859-1"

PostPosted: 20. October 2006 22:51
by Wiedmann
Have I forgot something?

I guess you don't have a "SET NAMES" query?

PostPosted: 31. October 2006 13:52
by Tiansen
izzy: yes I used that section and set default charset to default-charset="utf-8"

Where is that mysql config file if I have default installation? I tried adding that SET NAMES thing in at least 2 different config files and it still doesn't work. :?

PostPosted: 31. October 2006 14:07
by Izzy
If you mean the default php.ini file it is in:
xampp\apache\bin\php.ini

There is a my.ini file in my C:\Windows directory
and in:
xampp\mysql\bin there is a my file that shows as a link that you can drag into a text editor to read or edit the file.

PostPosted: 31. October 2006 14:14
by Tiansen
No, I meant default mysql config file with mysqld section to add "SET NAMES" init query.

I have already edited PHP ini file that you mentioned with no avail.

PostPosted: 31. October 2006 14:16
by Tiansen
Thank you for answer izzy. That is mysqld section in \Windows\my.ini:

[mysqld]
basedir=C:/Program Files/xampp/mysql
#bind-address=10.0.0.52
datadir=C:/Program Files/xampp/mysql/data
#language=C:/Program Files/xampp/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
init-connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_general_ci

I tried also this variant:
init-connect="SET NAMES utf-8"

And it still doesn't work.

PostPosted: 07. November 2006 15:04
by Tiansen
Oh god, no clues? :shock: