0

I have a large html form, which is submitted to a script and then data is entered into database.

For some reason my entered chars in database are not correct. It turn ä into ä

The files are the following:

page_varaa.php which includes the form form_haeverkkotunnus_data.php or if form is submitted, it does the database action.

The both php pages are encoded as UTF-8 without BOM, have a

header('Content-Type: text/html; charset=utf-8');

on top of the page. The table itself has collation

utf8_unicode_ci 

and on the index.php page I have

<head>
    <meta charset="utf-8">

I am using the msqli and enter the data like this into database:

$stmt = $db->prepare($sql);
$stmt->execute()

Database engine is innoDB

My database has a server connection colation of utf8_general_ci

Despite all this still I have bogus chars in database. What am I missing here?

Thank you so much

edit:

I triet to set table utf8_general_ci also, did not change anything :(

Owl
  • 689
  • 5
  • 15
  • 29
  • 1
    you need to set the connection to the database to use utf8, too. See this answer for details: http://stackoverflow.com/a/4361485/401704 – cypherabe Jul 15 '13 at 12:23

1 Answers1

0

Thank you so much cypherabe, I am not using PDO but your comment gave me the right direction, I had to set the charset for mysqli, like here;

http://php.net/manual/en/mysqli.set-charset.php

Owl
  • 689
  • 5
  • 15
  • 29