fawad
fawad

Reputation: 1353

charset issue with mysql

I'm trying to store the following line in mysql:

$data = "After 30μs, what fraction of the charge will remain?"

If I display $data on HTML Page I get the exact text but if i store this in database then i get this data on output I get the following :

After 30Î?s, what fraction of the charge will remain?

I have set charset=utf-8 but even then i'm not able to access the proper data with all the symbols. Is there anything I'm missing ????

Upvotes: 1

Views: 118

Answers (3)

nobody
nobody

Reputation: 10635

Make sure your column's charset is utf-8, then use this method for inserting:

INSERT INTO my_table VALUES( 
    _utf8'After 30μs, what fraction of the charge will remain?', ...
);

and this for reading:

SELECT BINARY my_column FROM my_table;

Upvotes: 0

user188654
user188654

Reputation:

Whats your MySQL server's default charset and collation? Try executing the following query before any other queries inside your scripts.

SET NAMES utf8 COLLATE utf8_general_ci;

BTW, are we talking about a MySQL server?

Upvotes: 0

Karolis
Karolis

Reputation: 9562

You need to set database connection encoding:

mysql_set_charset('utf8');

Or similar method, depending on your database library.

Upvotes: 1

Related Questions