misha312
misha312

Reputation: 1713

store Hebrew in database with utf- 8 encoding using php and mysql

I am building a web site with database in Hebrew (using php and mysql). on general I use chrome to test my job... today I tried explorer :-0 (yeh... you must be thinking "why the f*** would he do it... ;) ). I found out that all the data that is sent from explorer is stored in ????? and cannot be used.

I use <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> on the main page

and header('Content-Type: text/xml charset=utf-8'); on the php page that sends the xml files (after he receives get request)

on my connect.ini.php I included the following code:

mysql_query("SET NAMES 'utf8'",mysql_connect($host, $user, $password));

my ajax javascript is:

if(xmlHttp.readyState==4||xmlHttp.readyState==0){
   gender=document.getElementById("gender").value;                                                                                       
   xmlHttp.open("GET","file.php?gender="+gender , true);                                                                                    
   xmlHttp.send(null);
   }else{
        setTimeout('submit_quick_start_form()',1000);   
   }

as i said before in chrome everything is fine...

Please help guys...

Upvotes: 1

Views: 716

Answers (1)

user4749485
user4749485

Reputation: 1028


(click for full size)

Shown in the first 3 GETs, in order, I found that Chrome, Firefox, and IE all produce different results. But I guess theoretically, Firefox does it right. In any case, they all give the same result (next 3 GETs in order), if we encodeURIComponent() the input.value. Like such:

xhr.open('GET', location.href+"?"+encodeURIComponent(test.value), true)
......
<input type=text id=test name=test value="שלום מישה">

Upvotes: 1

Related Questions