homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Two Languages in One Column
Mysql table

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

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.



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

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?


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

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">
<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?


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

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");

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.


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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved