Welcome to WebmasterWorld Guest from 54.226.67.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Two Languages in One Column

Mysql table

     

abushahin

4:39 pm on Feb 3, 2012 (gmt 0)

5+ Year Member



Hi guys, I couldnt find a mysql forum specifically but as ive seen other mysql questions in this php forum i thought its ok as its to do with php rendering.

anyway i have a table column which has two different languages in it. so it has english and then arabic all in one sentence it stores correctly in the table field (i can see that in phpmyadmin), but when i retrieve it the characters are not show correctly, there is another column which has just arabic that shows perfecly.
i am using

mysql_query("set names utf8");


this works fine for one column but not the mixed one any ideas/suggestions appreciated.

enigma1

10:19 am on Feb 6, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



but when i retrieve it the characters are not show correctly

How do you render/check the output? Is it on a browser or you view the html itself.

Make sure the HTML charset is also utf-8. And during the mysql connection you setup the character set before selecting the database (not just the names). Also the db table should be setup with utf8. What's the precise collation of the table and column btw you see in phpmyadmin for the multilingual table?

abushahin

5:33 pm on Feb 6, 2012 (gmt 0)

5+ Year Member



thanks for the reply! I am rendering via php this is what i have:

<
?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>


the table collation is latin1_swedish_ci but the column is utf8_unicode_ci.
Ive changed the whole table to utf8_unicode_ci and mysql_set_charset('utf8'); when querying.
but no luck.

Previously the column was latin1_swedish_ci then when i inserted the values i couldnt see the output correctly that got fixed when i changed the column to utf8_unicode_ci and then i was able to see correct values.
when i query using phpmyadmin the results are fine and is displayed how its supposed to but when rendered to client i.e. browser it doesnt show correctly. Any ideas?

enigma1

6:39 pm on Feb 6, 2012 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Try utf8_general_ci for both table and column and test it. Write some text so both language strings (arabic and english) are inserted in the same row. Then check with phpmyadmin to make sure everything is good and the retrieve the row and render it, see what happens. And make sure you setup the charset right after connect and before selecting the db, ie:

mysql_query("set character set utf8");
mysql_query("set names utf8");
mysql_select_db($database);

I've tried it with foreign languages including arabic and works as expected. If it still doesn't work I would like to know too. I have a CMS that supports multilingual via my profile and uses exactly what I mentioned so you can see the source.

abushahin

11:56 pm on Feb 6, 2012 (gmt 0)

5+ Year Member



Hey enigma1 thanks for your replies!
I got to the bottom of it! I was using <dfn> tag and that wasn't rendering it correctly, Ive removed it and its fine, so now I know no more definition tag! Im not even going to bother using <dfn> im just using <em> now. So thanks
 

Featured Threads

Hot Threads This Week

Hot Threads This Month