In the application PHP5, all the values obtained through MySQL Query become '??????? '. It was originally a character set error. When installing MySQL 5, I have selected the default character set gb2312, but garbled characters are still returned. the solution is to connect to the MySQL server.
In PHP 5, all the values obtained through MySQL Query become '??????? '. It was originally a character set error.
When I installed MySQL 5, the default character set is gb2312, but garbled characters are still returned. the solution is to connect to the MySQL server, call a 'set names x' statement similar to the character set ). The following are my connection functions:
Function SQL _connect (){
Global $ MYSQL_HOST, $ MYSQL_USER, $ MYSQL_PASSWORD, $ MYSQL_DATABASE;
$ Connection = @ mysql_connect ($ MYSQL_HOST, $ MYSQL_USER, $ MYSQL_PASSWORD) or startUpError ('
Cocould not connect to MySQL database.
', 'Connect error ');
If (! Mysql_select_db ($ MYSQL_DATABASE ))
{
Include 'Install. php ';
DoInstall ();
Mysql_select_db ($ MYSQL_DATABASE) or startUpError ('
Cocould not select database: '. mysql_error ().'
', 'Connect error ');
}
SQL _query ('set names' gb2312 ''); // SQL _query is a custom query function. The key is this statement.
Return $ connection;
}