I have trouble with inserting strings that includes Turkish characters. I am trying to insert "öçşığüÖÇŞİĞÜ" as string.
I put the line indicated below into the head of php file:
header("Content-Type: text/html; charset=windows-1254");
I get data from ajax with (although it is not important, I write it)
$json = filter_input_array(INPUT_POST);
Here is insert command:
$query = "INSERT INTO users (name) VALUES ('" . $user->get_name() . "')";
Now, I tried two cases of assigning values to variables:
CASE 1
- php: $name = $json['name'];
- browser: öçşığüÖÇÅİÄÜ
- database: çşığüÖÇŞİĞÜ
CASE 2
- php: $name = iconv("UTF-8", "ISO-8859-9", $json['name']);
- browser: öçşığüÖÇŞİĞÜ
- database: çþýðüÖÇÞÝÐÜ
"1" is my assigning type of string, "2" is the result of "echo $user->get_name();" depending on the assignment at "1", and "3" is the value in database cell. I can get true result in "echo" in CASE 2, but corrupted result is inserted into database. My DB collation is: "utf8_turkish_ci".
(Php 5.4.17, MySQL 5.6.13)