CREATE TABLE langs (
id char(50) character set utf8 NOT NULL,
name char(50) character set utf8 NOT NULL,
meta char(50) character set utf8 default NULL,
error_text char(50) character set utf8 NOT NULL,
encoding char(50) character set utf8 default NULL,
PRIMARY KEY (id))
ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
CREATE TABLE strings (
string_id char(100) character set utf8 NOT NULL,
page_id char(50) character set utf8 NOT NULL,
en text character set utf8 NOT NULL,
de text character set utf8 NOT NULL,
hi text character set utf8 NOT NULL,
PRIMARY KEY (string_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
when i insert from php it shows as ?? ??? in the database. I even changed the mysql my.ini to this:
I also have the same problem:
When I look at mysql interface in the command prompt, the characters are unreadable.
However, when I display the records on my browser, everything is in order and it works fine.
I don’t know whether mysql in the command prompt window will display non-roman scripts correctly, but it does fine when accessing it from a web interface with a up-to-date browser. Do you need to read the records in the command prompt or can you get by with relying only on viewing from a browser?
The collation is irrelevant - Only the encoding matters. The encoding can be set in multiple places though and they all need to match up.
First: What encoding did you save your php-file in? Check in your text editor if you don’t know.
Second: On the page where you display the string, which encoding are you serving the page with? You can check this by right-clicking and selecting View Page Info.
kyberfabrikken spot on when i right clicked on my browser it was encoding on western European, so i changed it utf8, but why does php not cater for this. Even when I make it explicit in php like below it won’t work:
i just noticed I was not serving it with any encoding, hence why it did not render properly. so i placed a header(‘Content-Type: text/html; charset=UTF-8’); and it now works fine.
No worries - a lot of this is taken from Kevin Yank’s Book ‘Build Your Own Database-Driven Website’, chapters 3-5. You may want to check out this book.