I am trying to run this query:
SELECT trans FROM `dictionary` WHERE `word` LIKE 'Çiçek'
like this (relevant code):
function gettranslation($word){
return $this->query("SELECT trans FROM `dictionary` WHERE `word` LIKE '$word'");
}
function query($query){
$result=mysqli_query($this->conn, "set character_set_results='utf8'");
$result=mysqli_query($this->conn, $query);
return $row = mysqli_fetch_row($result)[0];
}
My mySQL table is made like this:
Word | Trans
-------------
Flower| Çiçek
-------------
Çiçek | Flower
When the $word
I pass to the gettranslation
function is Flower
, the result is Çiçek
. However when I do the reverse, the result is NULL
.
Also if I do var_dump
on it, I get nothing. Not even an empty array.
Strangely enough, when I run the same query in PHPmyAdmin it runs fine.
Help?
As far as I remember,
mysqli_query($con, "SET NAMES 'utf8'");
was required, like this: