In the use of PHP 5, the value obtained through the MySQL query all become '??????? ', the original character set is wrong.
I installed MySQL 5 o'clock, has chosen the default character set for gb2312, but still return garbled, the solution is to connect to the MySQL server, call a set of the same set names X statement (x for you set the character set). Here's my connection function:
function Sql_connect () {
Global $MYSQL _host, $MYSQL _user, $MYSQL _password, $MYSQL _database;
$connection = @mysql_connect ($MYSQL _host, $MYSQL _user, $MYSQL _password) or startuperror (' <p>could not connect to MySQL database.</p> ', ' Connect Error ');
if (!mysql_select_db ($MYSQL _database))
{
Include ' install.php ';
DoInstall ();
mysql_select_db ($MYSQL _database) or startuperror (' <p>could not select DATABASE: '. Mysql_error (). ' </p> ', ' Connect Error ');
}
Sql_query (' Set names "gb2312"); Sql_query is a custom execution query function, the key is this statement
return $connection;
}