So, I made a searching system test (This code searches items out of the "diakok" named database) and there is a problem with it. When I type in my name (Géró Kristóf) it says there are no names in the database like this, but when I write it as Gero Kristof, it finds that right (but it doesn't write out the name, because of these special letters), while there are é and ó instead of e and o in the database. I tried changing the encoding types also in the database and the code, but nothing works right. (With names which don't have special characters, it works just fine)
<?php
$keresesi_tipus = 'felhasznalonev';
$keresesi_kifejezes = trim($_POST['keresesi_kifejezes']);
header("Content-type: text/html; charset=utf-8");
if (!$keresesi_kifejezes) {
echo "Nem adott meg keresni való nevet. (1-es hibakód)";
exit;
}
if (!get_magic_quotes_gpc()) {
$keresesi_tipus = addslashes($keresesi_tipus);
}
@ $adatbazis = new mysqli('localhost', 'root', '', 'diakok');
if (mysqli_connect_errno()) {
echo "Hiba! Nem sikerült csatlakozni az adatbázishoz. (2-es hibakód)";
exit;
}
$lekerdezes = "SELECT * FROM diakok WHERE ".$keresesi_tipus
." LIKE '%".$keresesi_kifejezes."%'";
$talalat = $adatbazis->query($lekerdezes);
$talalatok_szama = $talalat->num_rows;
echo "<p>A keresésnek megfelelő diákok száma: ".$talalatok_szama."</p>";
for ($i = 0; $i < $talalatok_szama; $i++) {
$sor = $talalat->fetch_assoc();
echo "<p><strong>".($i+1).". Teljes neve: ";
echo htmlspecialchars(stripslashes($sor['teljes_nev']));
echo "</strong><br /> Felhasználóneve: ";
echo stripslashes($sor['felhasznalonev']);
echo "<br /> Kategóriája: ";
echo stripslashes($sor['kategoria']);
echo "<br />";
echo "</p>";
}
$talalat->free();
$adatbazis->close();
?>