0

I exported some tables in my mySQL database on my own server (localhost) to a web host using phpMyAdmin. The tables contain swedish special characters, and the CHARSET is set to latin1_swedish_ci. When imported, the characters look correctly in phpMyAdmin of the web host server, but when they are fetched and displayed on the web, there is a question mark (inside a diamond) instead of each special character.

If I update the data by fething the data into a form and then manually replace the question marks with the special characters and submit (thus updating the table), then the updated data shows correctly in the web when fetched.

But if I do the same thing but using the same update form on my own server where the fetched data displays correctly both in phpMyAdmin and web/localhost and setting the post attribute to the insert page on the web server, then that data does not display correctly (on the web).

I.e. this is the opposite problem of that explained in this post.

What might be wrong?

EDIT: As to the suggestion that using "UTF-8 all the way through" might solve the problem: My question more concerns how I might understand why a problem like this can occur. If the data looks ok in phpMyAdmin, does that mean that the problem lies simply in the fetching? Or might there still be something wrong with the data?

Community
  • 1
  • 1
emilyaro
  • 23
  • 3
  • You'll need to configure your connection to use the right charset as well. Using UTF8 should do it. See this answer for more details http://stackoverflow.com/a/6226763/813486 – Jeremy Giberson Apr 15 '15 at 21:14
  • I am using the exact same code on both local server and web server. Can different servers have different charsets as defaults, and thus they must be specified in the actual code to make sure you retrieve it in the same charset on both servers? – emilyaro Apr 15 '15 at 21:56

1 Answers1

1

You need to ensure the character set is the same across your connection to the database and the web page it is displayed on.

You are best to use UTF-8 all the way.

On your web page you will need something like this:

So the browser knows what to display.

noz
  • 1,863
  • 13
  • 14