I'm trying to read a file with japanese characters and then insert them into the database. I'm currently getting an error in the mysql syntax being caused by the characters. Can anybody help me with this issue in guiding me in the right direction of storing utf8 characters.
header("Content-Type: text/plain; charset=UTF-8"); // output as text file
header("Content-Type: text/html; charset=UTF-8");
$file = fopen("address2.txt", "r") or exit("Unable to open file!");
//Output a line of the file until the end is reached
$db->query("SET NAMES utf8");
$line = fgets($file);
$db->query("insert into hotels(address2) values('$line')");