March 9, 2012
Textarea not showing hebrew text from mysql
Question by Prateek
I’m trying to return some particular text from mysql into a textarea. Now this text returning from mysql has
collation=utf8_unicode_ci
and the charset is set by adding this line in my php file.
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-8-i" />
Cant figure out the problem here. Everything looks alright but why is the textarea not showing hebrew text? Instead it shows “???????” – Question marks.
Thanks.
Answer by Starx
During the data entry, or retrieval, the MySQL must be configured to accept unicode(UTF-8) data. There are number of ways, you can do this
-
Place this line on the database connection part
mysql_set_charset('utf8',$link); //$link is your connection identifier
-
Run
charset utf8
on CLI - Use
SET NAMES 'utf8'
as your first query to the database
Moreover, while outputting such data the screen, the html should be configured to understand unicode characters as well. Use
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
At the top of the displaying page.