How to solve the problem of storing or displaying garbled characters in PHP _php tutorial

Source: Internet
Author: User
You must remember to define the character types later in the writing process.
mysql_query ("Set names ' GBK '")
The solution is so simple.
Today I made a database query, releasing the code.
Copy CodeThe code is as follows:
/*
filename:query.php
Do:get and show the data
Author:www.5dkx.com
*/
Include_once ("conn.php");
Include_once ("include.php");
mysql_query ("Set names ' GBK '") or Die ("set word repertoires failed \ n");
mysql_select_db ($db) or Die ("Connection database failed!\n");
$exec = "SELECT * from $table";
Echo $exec;
$result = mysql_query ($exec, $conn) or Die ("query database failed \ n");
echo "

{
$city = mysql_result ($result, $cout, city);
$name = mysql_result ($result, $cout, name);
$phone = mysql_result ($result, $cout, phone);
echo "





"; for ($cout =0; $cout "; echo "City: $city"; echo "Name: $name"; echo "Phone: $phone"; echo " "; } echo "
";
?>

http://www.bkjia.com/PHPjc/321573.html www.bkjia.com true http://www.bkjia.com/PHPjc/321573.html techarticle you must remember to define the character types later in the writing process. mysql_query ("Set names ' GBK ') solves the simple method. Today do a database query, release code ...

  • 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.