tags:

views:

40

answers:

2

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

+3  A: 

Use UTF-8 encoding.

bazmegakapa
For both the database and the connection.
Alin Purcaru
+3  A: 

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: http://nl3.php.net/manual/en/function.mysql-set-charset.php

Check the character set of your current connection with:

echo mysql_client_encoding($conn);

See also: http://nl3.php.net/manual/en/function.mysql-client-encoding.php

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.

Stegeman
+1 for the clarity.
Anjali