I created an application whith UTF-8 database charset. When creating connection using php I am executing mysqli_query($link, 'SET CHARACTER SET utf8').
It was working fine on localhost with both SELECT, INSERT etc. I deployed the application on web with some sample data and quickly browsed the page I saw UTF-8 characters nicely.
The next day client called me data is showing like ?????? when I add some record through provided interface I was surprised he was right but On localhost it was working fine.
After some searching I found multiple answers like execute these queries
set character_set_client='utf8'set character_set_results='utf8'set collation_connection='utf8_general_ci'SET NAMES 'utf8'- and setting then encoding in response etc
None of them worked but this mysqli_set_charset($link, 'utf8') one.
My Question is
- Why It was working on localhost, and only
INSERT or UPDATEQuery was creating problem after deployment butSELECTwas working fine - What is the difference between
mysqli_set_charset($link, 'utf8')andmysqli_query($link, 'SET CHARACTER SET utf8')