I wrote a PHP file which should insert values in a MySQL database.
I explain my problem with an example.
include 'db_connect.php';
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
$title = 'knödel';
echo $title;
$sql="INSERT INTO RECIPES (title) VALUES ('$title')";
In the database, there is ‘kn’;
I cut the string from the umlaut.
If your database collation is Unicode or UTF-8, just do:
The only difference is the N character which makes it possible to insert Unicode data into the database.
And you have to take the security risks seriously. Use
mysql_real_escape_stringtogether with other required actions to protect against sql injections. (If you don’t do it now, you’ll forget it when writing a big real-world application.)