Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

php - UTF-8 Turkish Character on osCommerce

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>';
 }

 }

  ?>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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'");  

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...