PHPMySQL text garbled-PHP source code

Source: Internet
Author: User
Ec (2); MySQL version: mysql-4.1.21-win32.exe & nbsp; Apache version: apache_1.3.37-win32-x86-no_src.msi & nbsp; Operating System: WinXP & nbsp; + & nbsp; SP2 & nbsp; & nbsp; PHP version: php-4.4.3-Win32.zip & nbsp; "script" ec (2); "script"

MySQL version: mysql-4.1.21-win32.exe
Apache version: apache_1.3.37-win32-x86-no_src.msi
Operating System: WinXP + SP2
PHP version: php-4.4.3-Win32.zip

My website must support both Chinese and English, and other languages in the future.

So I used utf8 when creating a database.
I used PEAR + Smarty
The PHP code is as follows:
$ User = DB_DataObject: factory (''users '');
$ User-> query ("select * from users where user_id = 1 ");
$ User-> fetch ();
$ Smarty-> Assign (''user'', $ user );
$ Smarty-> display (''index. tpl '');
Template file:





6666



{$ User-> name}



However, if the question mark is displayed, it is normal in English.
1. You can also use PHPMyAdmin to display Chinese characters normally.
2. garbled characters are displayed at the command prompt.
How can I solve this problem? Thank you. I found information on the Internet, but it still does not work.






What encoding is stored in your database?

The data inventory is UTF-8, and At the same time, save the file as UTF-8 format...

$ User-> query ("set names utf8 ");
$ User-> query (& q

<

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.