我想让用户为他们创建个人资料。要做到这一点,我给了他们一些div的选择。每个div都有自己的id。选择选项并单击后,提交选定的divs' id被置于隐藏输入中,然后作为POST变量发送到profil_olustur.php。在该页面中,我使用此脚本:
header('Content-Type: text/html; charset=utf-8');
// DB connection is here
$baglan = mysql_connect($host, $user, $pass);
mysql_select_db($db);
include_once "fonksiyonlar/girdikontrol.php";
if (isset($_POST['profil_fakulte']) && !empty($_POST['profil_fakulte']) && isset($_POST['profil_bolum']) && !empty($_POST['profil_bolum'])) {
$profil_fakulte_temiz = kontrol($_POST['profil_fakulte']); //variable from hidden input
$profil_bolum_temiz = kontrol($_POST['profil_bolum']); // variable from hidden input
$ka = $_SESSION['kullaniciadi']; //username
mysql_query("SET NAMES 'utf8' ");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci' ");
$bilgi_ekle = mysql_query("UPDATE kayitli SET profiloldumu='1',fakulte='$profil_fakulte_temiz' , bolum='$profil_bolum_temiz' WHERE kullaniciadi = '$ka' " ); //Updating two columns(fakulte and bolum) in $username's row
$_SESSION['kayit_bilgi'] = 'Profilin oluşturuldu. Tekrar giriş yap'; // A message to inform user whether is profile created or not.
$_SESSION['girildi'] = 0; // Make user to logout
Header("Location: index.php"); // And goes index.php
} else {
Header("Location: profilolustur.php"); // if variables are not sent goes back the same page
}
当我更新用户的两列(fakulte和bolum)时,我无法使用土耳其语字符。它写了
Uçak ve Uzay Bilimleri Fakültesi
而不是
Uçak ve Uzay Bilimleri Fakültesi
或
U&cce
而不是
UCK
我非常惊讶,因为第二个甚至不涉及土耳其人的性格。此外,我可以修改fakulte
和bolum
列,我可以使用土耳其语字符,但我无法使用PHP。有什么问题?
虽然我应用了这些程序,但他们没有工作。
我在使用UPDATE查询之前或者在连接到数据库之后立即添加了这些代码 mysql_query(" SET NAMES' utf8'"); mysql_query(" SET CHARACTER SET utf8"); mysql_query(" SET COLLATION_CONNECTION =' utf8_turkish_ci'");
我补充说 标题(' Content-Type:text / html; charset = utf-8'); 到我的php文件和HTML文件
答案 0 :(得分:0)
尝试添加
setlocale(LC_ALL, 'tr-TR.utf8');
答案 1 :(得分:0)
确保您正在使用utf8_unicode_ci排序规则存储数据的表格和列。