0

I have used phpMyAdmin to export a database from my remote server to WAMP via SQL file. All php code is the same on both sites but the local site gets charset errors when pulling data out of the database (black diamonds with ? where apostrophes should be).

Database Collation (both): utf8mb4_general_ci Table Collation (both): utf8_general_ci Column Collation (both): utf8_general_ci

When I run mysqli_character_set_name() on the remote site it returns uft8 but the local site defaults to latin1.

If I set the local site to utf8 with mysqli_character_set_name() the black triangles turn to two white rectangles with black borders.

What am I missing?

HFTH
  • 1
  • Check that you've implemented everything on the checklist: [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – ADyson Feb 22 '21 at 12:10
  • Thanks for that @ADyson - I feel like I have done all of that: - I changed Database Collation to utf8 so now Database, table & column are the same - PHP I use mysqli_set_charset($conn, "utf8") after connection - var_dump of data returned from the db in teh php file contains the white rectangels (they are only black diamonds if I leave the mysql default set to latin1) – HFTH Feb 22 '21 at 12:32
  • Well presumably you missed something. Either that or your situation is different somehow from the standard one. But there's not enough info in your question to differentiate it from the standard situation. – ADyson Feb 22 '21 at 12:34
  • @ADyson, FYI I just had a fiddle in the local php.ini and changed the default charset to see what would happen... I got gibberish as you would expect but when I reset it to UTF-8 (as it was originally) and restarted all services it seemed to fix the issue. I am happy to admit I am way out of my depth with this but thought I'd keep you in the loop. Cheers. – HFTH Feb 22 '21 at 13:15
  • Perhaps it just needed a restart then! Glad you fixed it :-) – ADyson Feb 22 '21 at 13:17
  • @ADyson - It seems so. I just dropped the database to try again with the original, slightly mismatched charsets that seem to work on the live site... The diamonds were back. If I change the charset in my php with mysqli_set_charset() the old charset setting seems to persist (or at least the new doesn't really take effect). With a restart all is well. Really appreciate your help mate. – HFTH Feb 22 '21 at 13:22

0 Answers0