I use the following code to store and update data in my db.
<?php
header("Content-Type: text/html;charset=UTF-8", true);
mysql_connect("localhost", "test", "test") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// mysql_set_charset('UTF8');
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION = 'utf8_unicode_ci'");
mysql_query("UPDATE `test`.`english` SET age = '".$age."', city = '".mysql_real_escape_string($_REQUEST['city'])."', aboutMe = '".$_REQUEST['about']."' WHERE `english`.`username` = '".$_REQUEST['username']."' LIMIT 1 ;")
or die(mysql_error());
The code is working well. But if the string, e.g. “city” contains a ä,ö,ü it is stored as ?
So for example the word “Bär” goes to “B?r”.
I have already added these utf8 things but it does not help.
The server is only supporting php4.x
Edit: The DB is using latin1_general_ci as collation.
Use utf8 as collation, maybe
utf8_binorutf8_unicode_ci(The ci means it’s case insensitive so comparsions like “John” = “JOHN” return true). You can do this by running the following query in MySQL: