Jump to content

PHP and MySQL storing characters correct

Joveice

So I'm trying to store Æ, Ø and Å in a mysql but it turns it to jibrish, tho when I echo the result it's displayed correct. Row is set to utf8_swedish_ci. what is going on here?

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

I guess your html is ok? Then maybe it is database connection problem. How do you connect to your database? PDO takes options array as the 4th argument, and you can pass there MYSQL_ATTR_INIT_COMMAND with value SET NAMES utf8. You can also set charset in dns.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Mr_KoKa said:

I guess your html is ok? Then maybe it is database connection problem. How do you connect to your database? PDO takes options array as the 4th argument, and you can pass there MYSQL_ATTR_INIT_COMMAND with value SET NAMES utf8. You can also set charset in dns.

I use MySQLi

EDIT:

And if I go to the database and change the values manualy they will display as ? in the html

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

Maybe some fun stuff to read for the long run is the difference between MySQLi and PDO, it wontb e soon or maybe ever that you wanted to connect to an other type of DB instead of MySQL but PDO has some great other features.

Quote or mention me if not feel ignored 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×