MySQL returns garbled code when using php5. In php (as the mainstream development language) 5, all the values obtained by querying MySQL (the best combination with PHP) become ???????, It turns out that the character set is set incorrectly. I used MySQL (the best combination of php and PHP) in server 5) all the queried values are ???????, It turns out that the character set is set incorrectly.
When I installed MySQL (the best combination with PHP) 5, the default character set gb2312 was selected, but garbled characters were still returned, the solution is to call a "set names X" statement (X sets the character set for you) that is the same as the set character set) after connecting to the MySQL (the best combination of PHP and MySQL) server ). The following are my connection functions:
Function SQL _connect (){
Global $ MySQL (the best combination with PHP) _ HOST, $ MySQL (the best combination with PHP) _ USER, $ MySQL (the best combination with PHP) _ PASSWORD, $ MySQL (the best combination with PHP) _ DATABASE;
$ Connection = @ MySQL (the best combination with PHP) _ connect ($ MySQL (the best combination with PHP) _ HOST, $ MySQL (the best combination with PHP) _ USER, $ MySQL (the best combination with PHP) _ PASSWORD) or startUpError (
Cocould not connect to MySQL (the best combination with PHP) database.
, Connect Error );
If (! MySQL (the best combination with PHP) _ select_db ($ MySQL (the best combination with PHP) _ DATABASE ))
{
Includeinstall. php (as the mainstream development language );
DoInstall ();
MySQL (the best combination with PHP) _ select_db ($ MySQL (the best combination with PHP) _ DATABASE) or startUpError (
Cocould not select database:. MySQL (the best combination with PHP) _ error ().
, Connect Error );
}
SQL _query (set names "gb2312"); // SQL _query is a custom query function. The key is this statement.
Return $ connection;
}
In development php (as the mainstream development language) 5, all the values obtained by querying MySQL (the best combination with PHP) become ???????, It turns out that the character set is set incorrectly. I am in...