weird characters in database

Asked by At

hi i need to store the weird character in my database but when i am trying to do so the weird character is replace with unknown character. i am giving you one example when i am try to enter in Sönke Wortmann in database it is stored as Sönke Wortmann. i want to store above text as same as it was.please tell me how can i do so

1 Answers

Rene Terstegen On Best Solutions

You should use Unicode tables as well as a Unicode connection to your database.

Assuming you use MySQL:

Set the default character set of your table to utf8 and make sure the connection to your database is also using this character set:

$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);

See also:

Check the character set of your current connection with:

echo mysql_client_encoding($conn);

See also:

When creating your tables do something like this:

create table tableName (
    // Your table definition
) default charset = UTF8

If you have done these things and add weird characters to your table, you will see it is displayed correct.