1

I know there have been a lot of almost the same questions, but I still didn't find the answer to my problem. I want to place "les Îles Açores" into the db. But I get:

les Îles Açores

I tried usin:

  • SET Names 'ut8)
  • $mysqli->set_charset("utf8");
  • mysql_real_escape_string()
  • htmlentities (Here I got htmlentities, but I want to know if there's another way)

Code:

$name_fr = $_POST["name_fr"]; $name_nl = $_POST["name_nl"];
$arr_kollommen = array("NAME_FR","NAME_NL");
        $arr_waardes = array($naam_nl,$naam_fr);
        $obj_db->insert("landen",$arr_kollommen,$arr_waardes);

Does someone has an idea how to solve my litle problem? Thank you very much!

1
  • did you use "SET Names 'ut8)" or "SET NAMES 'utf8'". The former (as stated) is wrong Commented Nov 18, 2011 at 15:29

5 Answers 5

1

Make sure the table uses the correct CHARSET, for example:

CREATE TABLE myTable (
    one VARCHAR(255),
    two VARCHAR(255)
) DEFAULT CHARSET=utf8;
Sign up to request clarification or add additional context in comments.

1 Comment

The fields are VARCHAR(100) and charset = utf8_general_ci
1
  1. Make sure you actually write in UTF8 (meaning your IDE / editor you write your code must have encoding set to UTF8).
  2. Is the record corrupted both in the DB and on your page after you fetch it or only in DB?

Comments

0
$name_fr = $_POST["name_fr"]; 
$name_nl = $_POST["name_nl"];
$arr_kollommen = array("NAME_FR","NAME_NL");
$arr_waardes = array($naam_nl,$naam_fr);
$obj_db->insert("landen",$arr_kollommen,$arr_waardes);

Try using instead of encode to utf_8 decode. like this:

$name_fr = $_POST["name_fr"]; 
$name_nl = $_POST["name_nl"];
$naam_fr = utf8_decode($naam_fr);
$naam_nl = utf8_decode($naam_nl);
$arr_kollommen = array("NAME_FR","NAME_NL");
$arr_waardes = array($naam_nl,$naam_fr);
$obj_db->insert("landen",$arr_kollommen,$arr_waardes);

Comments

0

2 possible reasons i can see:

1) Your database doesn't feature UTF-8 fields

2) When you read your data from the server, you are not setting the connection as utf-8. If you have to set it utf-8 when writting you also have to set it utf-8 when reading.

Check using PHPMyAdmin if the data is wrecked... If it is, then it means that your SET names'utf-8' is not working...

Comments

0

Do you pass the "UTF-8" parameter into your htmlentities, and html_entity_decode this way ?

html_entity_decode($text,ENT_QUOTES , "UTF-8");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.