I’m using utf8_encode to make sure that the input from my users is transforming the special characters to a character where my MYSQL can do a search on. (My database is set in latin1_swedish.ci).
When I echo my query, I get a perfect query that I can run against my MYSQL (and I get an result). But when I do the same query via my PHP it doesn’t work.
$name = 'Widerøe'; $name = utf8_encode($name); SELECT id FROM type WHERE name = '$name' LIMIT 1 SELECT id FROM type WHERE name = 'Widerøe' LIMIT 1 $data = mysqli_fetch_assoc(mysqli_query($conn, "SELECT id FROM types WHERE name = '$name' LIMIT 1")); $operator_id = $data['id'];
Advertisement
Answer
I found a (easy) fix. I removed the utf8_encode and placed the following meta tag in the head of my body.
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>