2

How come that this:

$tekst = "ideeën";
$query = "UPDATE `home` SET `tekst`='" . $conn->real_escape_string($tekst) . "' WHERE `section` = 'welkom'";
mysqli_query($conn, $query) or die ("query fout " . mysqli_error($conn) );

Is stored in the database as: ideeën

8
  • Collation/character set issue. Commented May 8, 2015 at 18:22
  • your database column data type must be utf-8-bin if you want exact word to save. Commented May 8, 2015 at 18:22
  • That didn't work. Something else that may help someone come up with the solution: When I edit the text manually in PHPMyAdmin, it does work. Commented May 8, 2015 at 18:30
  • 3
    You shouldn't have to worry too much about how it appears in the database. As long as your treatment of the value going into the database and then drawing back out is the same, how it appears in your SQL client should be irrelevant. Commented May 8, 2015 at 18:54
  • I'll work with the SQL client side then if solving this seems like an issue, thanks anyways :) Commented May 8, 2015 at 19:03

1 Answer 1

1

Have you tried changing the character set of the connection?

/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
    exit();
} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
}

See http://php.net/manual/en/mysqli.set-charset.php

Sign up to request clarification or add additional context in comments.

1 Comment

I had this problem in the past. At one point had to fix it because I needed to share the data with another web app, but that involved also changing the data in the database.

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.