Hello, I try to insert text from JavaScript by using AJAX. I send text to a php file and from there to MYSQL database. I have no problem in isterting text even it has non-English characters in it with IE9, Firefox and Chrome. But in Opera, it inserts some different chars instead of correct non-English chars. Javascript code, with "ö" char being red, from where I make Ajax call is below:
Code:
if (document.kosul.bir_defa_dogru_cavabi_buldu.value == "") {
var yapilan_ornek = "if deyimi örnek 3"; // bu satır her tamamlamalı örnek için değişecek.
var kacincida_dogru_cevabi_buldu = document.kosul.yanlis_secim_sayisi.value.length + 1; // doğruyu kaçıncı seçenekte bulduğu = (yanlış seçim sayısı + 1)
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest;
}
else {
xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
}
var url = "http://localhost/tez/ornek_tamamlama_bilgisini_vt_gonder.php?hangi_ornek=" + yapilan_ornek +"&kacinci_secimde_dogru_cevabi_buldu="+kacincida_dogru_cevabi_buldu;
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
}
PHP code making the DB insertion is below:
Code:
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
function sqlConnect() {
$snc1 = mysql_connect ("localhost","root","*****");
$snc2 = mysql_select_db ("bote");
mysql_query ("SET NAMES 'latin5'"); // Türkçe harfleri içeren karakter setine geçiliyor.
$sncDeger= $snc1 and $snc2;
return $sncDeger;}
sqlConnect();
if (sqlConnect()){
$giristen_gelen_ogrenci_no = $_SESSION['username'];
// $hangi_tamamlamali_ornek = "if deyimi 1. tamamlamalı örnek";
$tsg = date('d.m.Y - H:i:s');
// if (mysql_query("INSERT INTO tamamlamali_ornek_bilgileri (id, hangi_tamamlamali_ornek, tsg) VALUES ('$giristen_gelen_ogrenci_no', '$hangi_tamamlamali_ornek', '$tsg')")) {
if (mysql_query("INSERT INTO tamamlamali_ornek_bilgileri (id, hangi_tamamlamali_ornek, kacinci_secimde_dogruyu_buldu, tsg) VALUES ('$giristen_gelen_ogrenci_no', '".$_GET["hangi_ornek"]."', '".$_GET["kacinci_secimde_dogru_cevabi_buldu"]."','$tsg')")) {
echo "<p>Bilgiler veritabanına eklenmiştir.";
}
else {
echo "Bilgiler eklenemedi...";
}
}
else {
echo "Bağlantı Kurulamadı...";
}
?>
"if deyimi örnek 3" is the right text inserted into the DB with IE9, Firefox and Chrome.
"if deyimi örnek 3" is the wrong text inserted into the DB with Opera.
MYSQL DB I use is configured to handle non-English chars correctly according to my knowledge.
I will appreciate your valuable helps.
Bookmarks