views:

42

answers:

2

Hello. I already have done this:

mysql_set_charset("utf8",$link); at the connection

mysql_query("SET NAMES 'UTF8'"); at the connection + on every table in database

changing from latin1 to utf8 collation + character for every table + columns

file have meta utf8 + header('Content-Type: text/html; charset=utf-8'); plus the files itself are formatted in utf-8( without bom)

where link is mysql_connect(), it shows the öäå characters fine when i take them out from database, but when i try to mysql_query UPDATE with stuff, that contains ÖÄÅ, it stores as Ã?¶à .. How can i fix this?

In the database the columns and so are, latin1_swedish_ci, as said it INSERT ÖÄÅs without problem, and echo it out too very well, but not when i try to UPDATE SET $user = 'ööö'

A: 

In the database the columns and so are, latin1_swedish_ci

This is your problem. You need to use a UTF-8 character set to store UTF-8 data.

What you are showing: �¶à is most likely UTF-8 data (which can consist of multiple bytes) being stored in a latin1 table.

Pekka
but.. how comes inserting ÖÄÅ works fine, but not Updating?
Karem
@Karem do you use a front-end like phpMyAdmin to insert the data? phpMyAdmin can detect and deal with character set differences.
Pekka
Dont really know what front-end is, but ok, ill try to change my columns to utf8 now
Karem
is there any way i could do this to them all fast, instead of going one column by one?
Karem
@Karem what software are you using to edit the database?
Pekka
im using phpmyadmin as you said
Karem
@Karem II thought there was an easy way of editing multiple columns at once, but I can't remember right now, and I don't have phpMyAdmin handy. It might be in there somewhere.
Pekka
Ok but i just did one quick check to make sure it really was that. I changed one column to utf8_swedish_ci collation, and utf8 character, and then i made a query("update set column1 = 'ÖÄÅ' i still get that strange characters?
Karem
@Karem is your incoming form (or wherever you type in the data) encoded as UTF-8 as well?
Pekka
@Pekka not much knowledge but i do have it set with mysql_set_charset("utf8",$link); as said in the question. The file are UTF8, where i have the query..
Karem
@Karem your HTML files need to be UTF8 encoded as well. I'm off now, but this question will give you everything you need: http://stackoverflow.com/questions/2662885/text-encoding-in-html-text-fields 'night!
Pekka
ok, everything in my database is not collating and char utf8, i have mysql_set_charset("utf8",$link);mysql_query("SET NAMES 'UTF8'"); for the connection, and header('Content-Type: text/html; charset=utf-8'); + meta + file itself encoded in utf8 and still those chars
Karem
actually a table/columns collation doesn't matter as long as it supports all stored characters.
Col. Shrapnel
A: 

mysql_query("SET NAMES 'UTF8'") on every table in database

can you be more specific? I see no way to use this query on every table.

it stores as �¶à ..

how do you check it?

Col. Shrapnel
Sorry, i found the problem, and its in a foreach, nothing at all about this, my fault i thought the foreach() could not do anything to the ÖÄÅ chars.. Please check here http://stackoverflow.com/questions/3645668/php-foreach-dont-understand-oaa
Karem