When using PHP 5, the values obtained through MySQL query all become '???????'. It turns out that the character set is set wrong.
When I installed MySQL 5, I selected the default character set as gb2312, but it still returned garbled characters. The solution is to call a "set names X" statement that is the same as the set character set after connecting to the MySQL server (X is your set character set). Below is 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;
}