1

I am currently working on a PHP website and I realized that the ς character from the Greek alphabet is not being displayed in an input tag when I load it then name from a database.

I am also unable to input the ς character into the text area.

I get this name:

Βασίλη

When the original name is this:

Βασίλης

This is the code for my input element:

<input type="text" name="firstname" value= '<?= $client->name ?>'>

At first I assumed that the default encoding on HTML5 is UTF-8 although I wasn't sure if this is the case so I added this HTML tag to my page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

This is the code in my profile.php file:

<?php
  $username = $_SESSION['username'];
  $query = "SELECT * FROM `users` WHERE username= '$username'";
  $result = $mysqli->query($query) or die(mysqli_error());
  $client = $result->fetch_object();
?>

This is the code in my connli.php file:

<?php
  $mysqli = @new mysqli('localhost', 'root', '', '2661');
  $mysqli->set_charset('utf8mb4');
  if ($mysqli->connect_errno) {
    die($mysqli->error);
  }
?>
tttony
  • 4,944
  • 4
  • 26
  • 41
  • Set everything you can to the UTF8 header. PHP header is a start. – Qirel May 20 '16 at 18:56
  • Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Qirel May 20 '16 at 19:09
  • I tried this already and nothing changed before I post the question. – Vasilis Da Vitzi May 20 '16 at 19:24
  • If you load it from a database, show the code that you get it with. @VasilisDaVitzi – Qirel May 20 '16 at 19:25
  • I forgot to mention that my database has utf8mb4_unicode_ci encoding. – Vasilis Da Vitzi May 20 '16 at 19:35
  • Okay, check the PHP headers (`header('Content-Type: text/html; charset=utf-8');`) and see that the actual tables are set to UTF8 (run `SHOW CREATE TABLE users;` in phpMyAdmin or something). And also check the actual file's encoding. – Qirel May 20 '16 at 19:42
  • Still can't find the solution. I discovered that when I press this specific letter only, my autofill recognises it but it's like invisible. All the other symbols and letters can be seen or be written. – Vasilis Da Vitzi May 20 '16 at 21:42

1 Answers1

0

The problem was not with the code.

The problem was because of the font, which could not display the character ς because that character was not supported by the font.

Simeon Leyzerzon
  • 18,658
  • 9
  • 54
  • 82