UTF-8 Turkish Character on osCommerce

拟墨画扇 提交于 2019-12-13 21:12:32

问题


I installed osCommerce v2.2 RC2 on http://www.cwcenerji.com. My problem is about left column (categories.php)

In database my category name is "Türkçe Kategori" but on front side I see it like T�rk�e Kategori

I tried a few things, also my database charset is UTF-8 but couldn't handle.

Here is categories.php;

<div class="title">
                    <img src="theme/images/icons/category.png" alt="Kategoriler"/>
                    <p>KATEGORİLER</p>
                </div>
                <div class="detail">

                    <ul class="categorytype">           








                <?php $query = mysql_query("select * from categories where parent_id = 0");
 $i = 0;
 while($row = mysql_fetch_array($query))
{
 $cat[$i] = $row;
$cat[$i]['categories_name'] = mysql_result(mysql_query("select categories_name from      categories_description where language_id = 1 and categories_id = '".$row['categories_id']."'"), 0);
$i++;
}

if(isset($session_id))
{
$cate = "&osCsid=$session_id";
}
else
{
$cate = "";
 }

 foreach($cat as $val)
 {
  //echo $val['categories_id'];
  $sub_query = mysql_query("select * from categories where parent_id = '".$val['categories_id']."'");
  echo '<li><a href="#">
                                <img src="theme/images/icons/stars.png" alt="Yıldız"/><span><b>'.$val['categories_name'].'</b></span></a>
                        </li>';

  while($sub_row = mysql_fetch_array($sub_query))
  {
  echo '<li><a href="#">
                                <img src="theme/images/icons/stars.png" alt="Yıldız"/><a href="kategori.php?cPath='.$val['categories_id'].'_'.mysql_result(mysql_query('select categories_id from categories_description where categories_id = '.$sub_row['categories_id'].' and language_id = 1'),0).$cate.'"><span>'.mysql_result(mysql_query('select categories_name from categories_description where categories_id = '.$sub_row['categories_id'].' and language_id = 1'),0).'</span></a>
                        </li>';
 }

 }

  ?>


回答1:


Here is the solution;

I've added these lines on categories.php (under

mysql_query("SET NAMES 'utf8'"); 
mysql_query("SET CHARACTER SET utf8"); 
mysql_query("SET COLLATION_CONNECTION = 'utf8_turkish_ci'");  



回答2:


I am using Notepad++ for these situations. Open your php file in notepad++ and encode it to "convert it to utf-8 without bom" from encoding menu. The foreign chars may be broken in the first time. After converting progress you can alter the chars like "T�rk�e" to "Türkçe" from the text editor. This may help you.



来源:https://stackoverflow.com/questions/18489073/utf-8-turkish-character-on-oscommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!