Textarea no muestra texto hebreo de mysql

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.

Gracias.

preguntado el 09 de marzo de 12 a las 13:03

Is your mysql connection set to UTF8 (SET NAMES 'uft8')? Is your HTML document encoded in UTF-8? -

I'm sorry i dont know how to set a mysql connection to utf8. Could you please clarify that? -

Your first query after connecting to the database should be SET NAMES 'uft8' -

mixing/matching charsets like that will just corrupt things. You should maintain the SAME charset throughout the entire pipeline. -

2 Respuestas

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

  1. Place this line on the database connection part

    mysql_set_charset('utf8',$link); //$link is your connection identifier
    
  2. Corral charset utf8 on CLI

  3. Utilizan 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.

respondido 09 mar '12, 14:03

after putting mysql_set_charset it shows characters that look like �§��× �� ��×�� ����¤��� ���©���×� ���§�¦��¢�, - Prateek

@Prateek, the meta tags, should be the correct one. Use this <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> on the top of the page - estrellax

Try this set up.

    //  encode web page 'utf-8' which holds the input form
<!DOCTYPE html> 
<html lang="en"><head><meta charset="utf-8">

//  Form submit from webpage 
$text = stripslashes($_POST['text']);

//  connect to database         
$db = mysql_select_db("$my_databasename",$conn)
    or die("ERR; Database");

//  setup UTF-8 on pipe 
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $conn);

mysql_query("SET NAMES 'UTF8'");

$text = mysql_real_escape_string($text);

// insert to mysql here

Remember to encode the web page that displays / returns the output from mysql. It is good practice to declare utf-8 encoding on all web pages by default unless you have other reason not to.

Respondido 04 Abr '12, 23:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.