Query database data garbled to solve

Source: Internet
Author: User
Both 1.php and HTML are utf-8
2.convention.php inside the ' default_charset ' and ' utf-8 ',
It's not 3.dbmysql.class.php $result [] = Auto_charset ($row, gb2312, UTF8)
Automatic conversion character set supports array conversion
function Auto_charset ($fContents, $from, $to) {
$from = Strtoupper ($from) = = ' UTF8 '? ' Utf-8 ': $from;
$to = Strtoupper ($to) = = ' UTF8 '? ' Utf-8 ': $to;
if (Strtoupper ($from) = = = Strtoupper ($to) | | empty ($fContents) | | (Is_scalar ($fContents) &&!is_string ($fContents))) {
If the encoding is the same or the non-string scalar is not converted
return $fContents;
}
if (is_string ($fContents)) {
if (function_exists (' mb_convert_encoding ')) {
Return mb_convert_encoding ($fContents, $to, $from);
}elseif (function_exists (' Iconv ')) {
Return Iconv ($from, $to, $fContents);
}else{
return $fContents;
}
}
ElseIf (Is_array ($fContents)) {
foreach ($fContents as $key = = $val) {
$_key = Auto_charset ($key, $from, $to);
$fContents [$_key] = Auto_charset ($val, $from, $to);
if ($key! = $_key) {
Unset ($fContents [$key]);
}
}
return $fContents;
}
else{
return $fContents;
}
}


Can't solve the-----of novice help


Reply to discussion (solution)

If you only query the database, you can remove Utf-8 data as long as set names UTF8. Of course. Your table must be UTF8 encoded.

PHP and HTML are utf-8.
Then execute the SQL command set names UTF8 after connecting to the database
Of course this refers to the case where the database is MySQL and the field is designed to support wide characters



PHP and HTML are utf-8.
Then execute the SQL command set names UTF8 after connecting to the database
Of course this refers to the case where the database is MySQL and the field is designed to support wide characters
Where is set names UTF8?? Which file of the Thinkphph folder is it?

' Default_charset ' = ' utf-8 ',//default output code
' Db_charset ' = ' utf8 ',//Database encoding defaults to UTF8

THINKPHPH don't need you set names UTF8
He'll do it himself.

Found the root of the two sentences Ah Rub
$job =m ("Form");
$list = $job->where ()->find ();
$job =m ("Form");
$list = $job->select ();
Nothing else has changed.
Novice Don't squirt

mysql_query (' Set names Utf-8 ');

Garbled, there must be a different character code, you may build the library when the code is not the same, you can view the library code, show create Datebase library name encoding consistent is not garbled

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.