Jump to content

UTF-8 from BD doesn't match UTF-8 from website


JoaoPedroCG

Recommended Posts

Hey everyone!

 

I'm posting here today because I have a HUGE problem and need help to resolve this ASAP..

 

Here it goes:

I have a database that have some rows already;

I was asked to do a "DB management website" for that DB;

the only problem is that when I fetched the rows from the database to display onto the website, the utf-8 errors start to appear:

1º characters like "ã" and "á" become different things (a square with a ? in them)

2º when I try to insert values from the website to the database, it happens the same thing..

 

I have used utf8_decode and utf8_encode but nothing has worked out for me..

 

Thanks in advance for your patience and sorry for my English not being the best to explain the problem..

Link to comment
Share on other sites

- The table columns (the text ones) need to be in utf8 format

- The table itself and the database should also have it as the default encoding

- You need to be connected to the database using utf8 encoding before any data is exchanged

- Your code needs to treat all strings as multibyte strings - that means no strlen() or substr() (and others) and instead using the mbstring extension's equivalents

- Your Content-Type response header and/or webpages need to mention the utf-8 encoding

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.