The infinity (∞) symbol gets converted to ∞ when it is inserted into my MySQL table by a PHP script, but if I insert it directly from phpMyAdmin, it inserts correctly. The symbol is passed to the PHP script by a GET call with the JavaScript function encodeURIComponent() around the contents. The field in the MySQL database is utf8_swedish_cl. How do I get ∞ to insert as ∞ into the database?
Asked
Active
Viewed 1,835 times
3
Alan Moore
- 71,299
- 12
- 93
- 154
James Simpson
- 13,210
- 26
- 78
- 107
-
I know this has not much to do with the answer but just to point out, when you retrieve the data, it will be in the correct format/correctly encoded. I guess it's just the way MySQL likes to represent non-ASCII characters. – Waleed Amjad Jan 15 '10 at 01:06
4 Answers
1
Are you sure that phpMyAdmin is doing it right? ∞ Looks a lot like a UTF8 character stored in a latin-1 column.
What do you get when you do this select hex(column_name) from the_table?
If it's
E2889E, then your connection is UTF8, your column may not be.If it's
C3AC, then your connection is latin-1 and your column is utf8.If it's
EC, then both your connection and column are latin-1
Here's a quick way to verify that the column's encoding is UTF8:
select
column_name, character_set_name, collation_name
from
information_schema.columns
where
table_name = '_your table_'
Seth
- 42,464
- 10
- 85
- 118
0
Are you setting SET NAMES utf8 before inserting the content into the database?
meder omuraliev
- 177,923
- 69
- 381
- 426
-
That does work to insert it correctly, though it still displays incorrectly. I'm going to use Alix Axel's answer from the link to get everything UTF-8 all the way through. – James Simpson Jan 15 '10 at 01:32
0
Don't forget the "query" SET CHARACTER SET utf8 at the beginning of your scripts.
zneak
- 130,082
- 41
- 248
- 315