This is a discussion on Charset driving me crazy! within the MySQL forums, part of the Database Server Software category; --> Hello! This is driving me crazy. I use php to query MySQL. Then the results are displayed on a ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello! This is driving me crazy. I use php to query MySQL. Then the results are displayed on a webpage. All accented characters, umlauts, etc. are displayed incorrectly on the webpage. I included "echo mysql_client_encoding();" in the php script and it says the charset is latin1_swedish_ci. However, both phpMyAdmin and Navicat say that ALL charsets are set to UTF8 at the server, database and table level. Where is this damn latin1 charset coming from? Any help will be appreciated. Thanks in advance. Diego |
| |||
| correo@ironcito.com wrote: > > This is driving me crazy. I use php to query MySQL. What MySQL version do you use? What is the (default) character set (and collation) at server/database/table/column level? Which PHP extension do you use to connect to MySQL? The old 'mysql' extension does not know about character sets. Maybe you would like to switch to the (newer, better, bigger) 'mysqli' extension. > Then the results are displayed on a webpage. Do you set a 'content-type' header with character set information? What encoding do you use to store the data? > All accented characters, umlauts, etc. are > displayed incorrectly on the webpage. > both phpMyAdmin and Navicat say that ALL > charsets are set to UTF8 at the server, database and table level. What does the database say (SHOW VARIABLES LIKE 'char%', SHOW CREATE TABLE ..., SHOW CREATE DATABASE ...)? More important - does your MySQL client specify a connection character set? Last not least: have you read the chapter on character set and collation support in MySQL? Fast recipe to avoid character set problems: 1. store all strings in UTF8 encoding 2. connect to the database with UTF8 connection setting 3. emit a content-type header specifying UTF8 encoding XL |
| ||||
| Just as a side note. Apache by default encodes it's served web pages as latin1. That might be how your pages are coming out in the wrong encoding. That is if you are using apache. Kirk correo@ironcito.com wrote: > Hello! > > This is driving me crazy. I use php to query MySQL. Then the results > are displayed on a webpage. All accented characters, umlauts, etc. are > displayed incorrectly on the webpage. I included "echo > mysql_client_encoding();" in the php script and it says the charset is > latin1_swedish_ci. However, both phpMyAdmin and Navicat say that ALL > charsets are set to UTF8 at the server, database and table level. Where > is this damn latin1 charset coming from? Any help will be appreciated. > Thanks in advance. > > Diego > |