PHP read data output garbled from MySQL

Source: Internet
Author: User
Mysql:



PHP files are as follows:



Header ("content-type:text/html; Charset=utf-8 ");
$index = 0;
$con = mysql_connect ("localhost", "root", "");
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("Test", $con);

mysql_query ("Set names ' UTF8 '");
mysql_query ("Set Character_set_client=utf8");
mysql_query ("Set Character_set_results=utf8");

$result = mysql_query ("SELECT * from Test_list
Limit 0,4 ");

while ($row = Mysql_fetch_array ($result))
{
$load _crouse_array[$index] = Array (
' subject_id ' = $row [' subject_id '],
' Subject_title ' = $row [' Subject_title '],
' Subject_url ' = $row [' Subject_url '],
' Subject_belong ' = $row [' Subject_belong '],
' Creat_time ' = $row [' Creat_time ']
);
$index + +;
}
mysql_query ("INSERT into ' test ') ' test_list ' (' subject_id ', ' subject_title ', ' subject_url ', ' subject_belong ', ' Creat_ Time ') VALUES (' 100005 ', ' Test text ', ' Test_url ', ' excel_crous ', ' 2014-08-10 ');
Echo Json_encode ($load _crouse_array);
echo "Test Chinese Chinese";
?>



The result of the final output:

Also inserted records in the database in the Chinese part is also displayed as????.
I use eclipse programming to this issue, and then directly using text editing software notepad++ the same problem. Environment for Windows7,xmapp, use Chrome browser.


Reply to discussion (solution)

Please help the great god of the forum to see where the problem arises. Why Chinese has been output garbled. My little brother is here humbly.

This is not garbled this is you use JSON encryption, you want to check the words in the output and then decrypt it.

You this $load_crouse_array array after json_encode processing data, not what garbled, but Chinese is processed by Unicode.
Output Print_r ($load _crouse_array); This will know if it's garbled.

You this $load_crouse_array array after json_encode processing data, not what garbled, but Chinese is processed by Unicode.
Output Print_r ($load _crouse_array); This will know if it's garbled.


Thank you for your help.


This is not garbled this is you use JSON encryption, you want to check the words in the output and then decrypt it.


Also thank you.

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