09/10/2018, 23:26
Lỗi hiển thị TiếngViệt, giúp em với mấy anh ơi.gấpgấp
Em có làm một cái Shop, trong phpMyAdmin em đã set là UTF-8, tiếng việt có dấu hiển thị t rất tốt. Trong các trang em viết em cũng cấu hình charset=UTF-8, nhưng khi chạy thì những phần có truy xuất từ cơ sở dữ liệu hiển thị toàn ký tự lung tung, còn những phần tĩnh khác thì Tiếng việt rất tốt. Em không biết cách khắc phục seo nữa, mấy anh chỉ giúp em với, em xin hậu tạ mấy anh, em cần gấp quá. Hix.hix...em dốt lắm mấy anh đừng la tội nghiệp
Bài liên quan
+ Client agent enc lúc nhập
+ Client conn vào MySQL lúc nhập
+ Server enc của MySQL lúc nhập
+ Table type lúc nhập
+ Connection enc lúc xuất.
Bạn cần đảm bảo các yếu tố này đồng bộ là OK. Nếu ko nhập thì bạn đang sử dụng conn enc lúc xuất là iso-8859. Cách chỉnh có ghi rõ trong tài liệu của MySQL.
{
global $SQL_DBASE;
global $SQL_USER;
global $SQL_PASS;
global $SQL_HOST;
global $lang;
$this->DBASE = $SQL_DBASE;
$this->USER = $SQL_USER;
$this->PASS = $SQL_PASS;
$this->HOST = $SQL_HOST;
$this->LANG = $lang;
$conn = @mysql_connect($this->HOST,$this->USER,$this->PASS);
if(!$conn) {
$this->error('ConnectServerError');
}
if(!mysql_select_db($this->DBASE,$conn)) {
$this->error('ConnectDatabaseError');
}
if(!mysql_query("SET NAMES 'utf8'",$conn));
$this->CONN = $conn;
}
function error($text)
{
//$no = mysql_errno();
//$msg = mysql_error();
echo "<br><br><center><h4>[ConnectDatabaseError]</h4></center><br>";
exit;
}
////////////////Select SQL//////////////
function select ($sql="", $column="")
{
if(empty($sql)) {
return false;
}
if(!eregi("^select",$sql)) {
$this->error($lang['SqlWrong']);
return false;
}
$conn = $this->CONN;
$results = mysql_query($sql,$conn);
if( (!$results) or (empty($results)) ) {
//$this->error($this->LANG['SelectEmpty']);
return false;
}
$count = 0;
$data = array();
while ( $row = mysql_fetch_array($results)) {
$data[$count] = $row;
$count++;
}
mysql_free_result($results);
return $data;
}
/////////// Insert SQL ///////////////
function insert ($sql="") {
if(empty($sql)) {
return false;
}
if(!eregi("^insert",$sql)) {
$this->error($this->LANG['SqlWrong']);
return false;
}
$conn = $this->CONN;
$results = mysql_query($sql,$conn);
if(!$results) {
//$this->error($this->LANG['InsertFail']);
return false;
}
return true;
}
if(!mysql_query("SET NAMES 'utf8'",$conn));
utf-8
po' chym