我想让用户为他们创建一个配置文件。为了做到这一点,我给了他们一些div选项。每个div都有自己的id。当选项被选中并点击提交时,选中的div的id被放置到隐藏输入中,然后作为POST变量发送到profil_olusustr .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。有什么问题吗?
尽管我应用了这些程序,它们还是不起作用。
- 删除整个数据库并重新创建,并为 选择utf8_general_ci
我在使用UPDATE查询之前或连接到数据库之后添加了这些代码mysql_query("SET NAMES 'utf8' ");mysql_query("SET CHARACTER SET utf8");mysql ("SET COLLATION_CONNECTION = 'utf8_turkish_ci' ");
我补充道头('的content - type: text/html;charset = utf - 8 ');我的php文件和HTML文件
尝试添加
setlocale(LC_ALL, 'tr-TR.utf8');
确保要存储数据的表和列使用utf8_unicode_ci排序规则。