Jump to content

PHP Some page my accented char appear and some pages no and replaced by '?'..


pascal_22

Recommended Posts

Hello,

 

I have a website. in fact i developp a new design for my web site and i set the meta tag like this

<meta charset="utf-8">

:

 

so my accents appears. i replace my accent with the good html accent ?=é .....

 

But in some page, the city name don't display accented charator well. It replace it by '?'

BUT in MySql database, i see correctly the accent.... ?

Why? and how show i setup mu database to only be in utf-8...?

 

Thank a lot!!

Link to comment
Share on other sites

The reason for this is that the HTTP header overwrites the meta-tag

 

Can you provide a source to this? I really doubt that the header would overwrite the META tag as that would be rendered last and surely take precedence.

 

As to the Original Post:

 

Make sure your database tables / columns are also set to UTF8 as well as the form that submits the data to the database. If any of them (output / input / storage) are not UTF8 you will get undesired results.

Link to comment
Share on other sites

premiso: It is quite easy to verify this yourself, you know. All it takes is saving a site as UTF-8, declaring it as some other charset in the HTTP headers, and use the correct in the meta-tag. ;)

To be fair I should have written "overrides", not "overwrites". As the former would be 100% correct and accurate, contrary to the latter.

 

Alternatively you can check out either this thread on WebmasterWorld or the one on StackOverflow. I'm sure there are lots of other sources that will confirm this as well.

I also recommend the article "Handling character encodings in HTML and CSS" on W3.org, while it may not explicitly state that HTTP headers take precedence over meta-tags there is a lot of useful information in it.

Link to comment
Share on other sites

Yes, that's wrong. Make sure that everything uses UTF-8, and you'll see that your work becomes that much easier all of a sudden. ;)

Easiest way to convert your database is to make a dump of it, then modify the dump-script to use SET NAMES 'utf8'; at the top, and DEFAULT CHARSET=utf8 at the end of every table definition. Then, after testing that it actually works, drop the old database and import the script anew.

 

If you cannot shut down your page while doing this, or if you're in danger of losing data if you do it in this way, then it is possible to update a live database. It's a far more complex and brittle process, however, and as such I do not recommend it. So only contemplate it if there is no other way.

Link to comment
Share on other sites

  • 2 weeks later...
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.