Jump to content

special/foreign characters problem


agrafuese

Recommended Posts

hello all, i have a big problem here that i hope someone can help me solve. i recently moved servers and had to export my mysql data from my old server and import it into my new server. when i did this, my data seemed to be fine (looks right in phpmyadmin), but when it comes up on a page in my site, any foreign/special characters (such as Ö, etc) show up as question marks on the page. i didn't have this problem before when my data was on the old server, and i've done nothing differently in my scripts that would cause this. the mysql version on the old server was 5.xx and the version on the new server is actually 4.xx. does this have anything to do with it? my data fields are collated as "latin1_swedish_ci" on both the old and the new server. when i imported the data onto the new server though, i had to choose "utf-8" because for some reason, importing it with "latin1" gave me problems (sorry i can't specify because i've forgotten what those problems were...this was a couple days ago). is it because of using "utf-8"? can anyone clue me in on what's going on here? i know it must have to do with a character set conversion issue of some sort, but i can't figure it out. thanks in advance!

Link to comment
Share on other sites

It sounds like your data is in UTF-8, but your meta tag is not specifying UTF-8. It should be as simple as updating this tag and making sure that all of your database connections are using UTF-8; however, going from single byte to multi-byte data may really botch up any string processing you have going on.

 

Can't you make a test database to attempt a Latin-1 import with and try to get things back to the way they were?

Link to comment
Share on other sites

thank you so much for the quick reply. i just set up a test database right now, and i re-imported my data there in "latin1" encoding instead of "utf8". the problem with this is:

 

when i use "latin1" to import the data, i get improper characters in phpmyadmin. for example:

 

the word "Östergötland" shows as "Östergötland"

 

however, when i view this data on my actual website, it shows up fine.

 

when i use "utf8" to import the data, i get PROPER characters in phpmyadmin. however, when i view the data on my actual website, i get improper characters. so "Östergötland" will show fine in phpmyadmin, but on the actual site it shows as "?sterg?tland"...

 

the meta tag on my site is:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

 

should i change the charset to utf8 as you suggested? it seems odd that i would have to do this now, but i didnt have to do it before i moved servers. any idea why?

Link to comment
Share on other sites

Not knowing what all of your code is doing, it's best to keep the data is the same encoding: Latin-1 (ISO-8859-1). I've never worked with phpmyadmin, but I'm guessing it may have an option that allows you to configure the display and/or database connection encoding.

 

Does the data appear correctly at the MySQL CLI?

Link to comment
Share on other sites

Ahhh, now it makes sense. Yes, you seem to be correct - the mysql CLI does show the proper characters, even when phpmyadmin shows the improper characters. i believe it is a display problem in phpmyadmin. so importing with "latin1" IS the way to go, but phpmyadmin is just interpreting the data wrong. i will try to find out the best way to set phpmyadmin's display settings, and i will reply here with the solution in case anyone else has the same problem as me in the future. thank you so much for your help so far.

Link to comment
Share on other sites

Just an update:

 

I'm unable to figure out how to make phpmyadmin display my special/foreign characters properly. For now, I am just refraining from using phpmyadmin to edit data, since inserting/updating rows with special/foreign characters via phpmyadmin causes my data to be displayed on my site as "?" (question marks), but inserting/updating rows from within my scripts works perfectly fine. on the flip-side, if i insert/update a row from within my scripts, phpmyadmin shows random characters in place of special/foreign characters.

 

Example: if i use my scripts to insert a row containing an "Ö" character, phpmyadmin shows the character as "ö". While this is frustrating, it isn't affecting the actual data, because a query run via mysql CLI shows the "Ö" character properly, and like I said, it shows up on my site properly as well. If anyone knows the remedy to make phpmyadmin display the proper characters, please let me know. I'll be checking phpmyadmin support forums in the meantime. Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.