Collect weather coding related issues

Source: Internet
Author: User
Collect Weather coding problems

Set_time_limit (0);
Connect_sql ();
$names = Trim ($_get[' names ');
$id = get_id ($names);

if ($id) {
$url = ' http://m.weather.com.cn/data/'. $id. HTML ';
$host = ' http://www.weather.com.cn/';
$files = @file_get_contents ($url);
$data = Json_decode ($files);

$content _encoding = mb_detect_encoding ($data, Array (' UTF-8 ', ' GBK '));
$datas = Iconv ($content _encoding, ' Utf-8//ignore ', $data);
Var_dump ($data);
}

function get_id ($names) {
$sql = "Select City_bh from city_id WHERE city_name = ' {$names} '";
$rel = mysql_query ($sql);
$row = Mysql_fetch_array ($rel);
$id = $row [' City_bh '];
return $id;
}

function Connect_sql () {
$con = mysql_connect (' localhost ', ' root ', ' 123456 ') or Die (' MySQL error: '. mysql_error ());
mysql_select_db (' Test ');
mysql_query (' Set names UTF8 ');
}
?>
The page has been converted into utf-8 mode, but it's still garbled.

Share to: more


------Solution--------------------
Put your code test, no problem, there is no garbled! You see your program file itself has not been saved into the UTF8 format!
------Solution--------------------
Does your code work correctly?
Please give the correct test parameters
  • 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.