1. Preliminary Checkups
A. Check if the table collation is set to "utf8_general_ci" from table operations
B. Check if the .php file is saved in utf8 encoding
These two things are VERY VERY important. Most of the times these are the two things people overlook. I personally spent many hours wondering and pondering about what I was doing wrong until I finally figured out that I saved the .php file in another encoding.
B. Check if the .php file is saved in utf8 encoding
These two things are VERY VERY important. Most of the times these are the two things people overlook. I personally spent many hours wondering and pondering about what I was doing wrong until I finally figured out that I saved the .php file in another encoding.
2. The Magic Line
After connecting to the MySQL database, you will need to set the character encoding to UTF8 like this in your PHP code
mysqli_query($con,"SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
This code tells the script to do all the operations after it in UTF8 character encoding.
0 comments:
Post a Comment