tags:

views:

82

answers:

3

I have a mysql database which Im trying to submit values to through a php file from a form.

If I manually insert values to the table 'myTable' with special characters like the swedish åäö letters, it works fine.

But when I am trying to use 'INSERT INTO' after a form is submitted on my page, to insert values to the table, all special characters turn out weird... Like symbols...

All collations are set to utf-8-swedish!

NOTE1: If I echo the values 'POSTED' from the form submit, the special characters are shown proberly. So its not the php file or the form itself.

NOTE2: All documents are set to utf-8

Thanks

+1  A: 

Ensure with mysql_set_charset that the MySQL connection charset is UTF-8.

Eemeli Kantola
Great minds think alike. :-)
middaparka
+2  A: 

Is the HTML doctype set to UTF-8 as well?

Also, have you checked the MySQL connection character set? (You can verify this with 'mysql_client_encoding' and set it with 'mysql_set_charset'.)

Irrespective, when you extract the data from the database and echo it does it display correctly?

middaparka
+1  A: 
mysql_query("SET NAMES 'utf8'") or die(mysql_error()); 
mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error());

THIS FIXED IT!

Camran
Do you actually need SET NAMES? Also, isn't it preferable to set the character set programatically (as per my answer) rather than via a query where you'll have to send a full query to the server, etc.
middaparka