Using PHP 5 o'clock MySQL return garbled solution _php Tutorial

Source: Internet
Author: User
In the use of PHP (as the current mainstream development language) 5, through the MySQL (and PHP collocation of the best combination) to get the value of all become???????, the original character set is wrong.

I am installing MySQL (and the best combination of PHP) 5 o'clock, has chosen the default character set of gb2312, but still return garbled, the solution is to connect MySQL (and the best combination of PHP) server, a set of the same set of characters called "Set names X" statement (x For the character set you have set). Here is my connection function:

function Sql_connect () {
Global $MySQL (best combination with PHP) _host, $MySQL (best combination with PHP) _user, $MySQL (best combination with PHP) _password, $MySQL (best combination with PHP) _ DATABASE;

$connection = @MySQL (best combination with PHP) _connect ($MySQL (best combination with PHP) _host, $MySQL (best combination with PHP) _user, $MySQL (best combination with PHP) _ PASSWORD) or Startuperror (

Could not connect to MySQL (the best combination of PHP collocation) database.

, Connect Error);
if (! MySQL (best combination with PHP) _select_db ($MySQL (and PHP collocation) _database))
{
Includeinstall.php (as the current mainstream development language);
DoInstall ();
MySQL (and PHP collocation best combination) _select_db ($MySQL (and PHP collocation of the best combination) _database) or Startuperror (

Could not select database:. MySQL (and PHP collocation of the best combination) _error ().

, Connect Error);
}
Sql_query (Set names "gb2312"); Sql_query is a custom Execute query function, the key is this statement
return $connection;
}

http://www.bkjia.com/PHPjc/508723.html www.bkjia.com true http://www.bkjia.com/PHPjc/508723.html techarticle in the use of PHP (as the current mainstream development language) 5, through the MySQL (and PHP collocation of the best combination) to get the value of all become???????, the original character set is wrong. I'm in Ann .

  • Related Article

    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.