0

does anyone know the Collation which will allow me to display foreign keys such as áé like that without displaying them as ?.

how I'm displaying

    <?php

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
    ?>
            <tr><td><?=$row["id"]?></td> 
            <td><?=$row["game"]?></td>
            <td><?=$row["server"]?></td>
            <td><?=$row["datetimepicker1"]?></td>
            <td><?=$row["et"]?></td>
            <td><?=$row["sc"]?></td>
            <td><?=$row["ss"]?></td>
            <td><?=$row["ec"]?></td>
            <td><?=$row["es"]?></td>
            <td><?=$row["attending"]?></span></td>
    <td><p data-placement="top" data-toggle="tooltip" title="Delete">
   <button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" >
   <span class="glyphicon glyphicon-trash"></span></button></p></td>
<?php } 
} else { ?>
    <td colspan="5">0 results</td>
<?php } ?>

enter image description here

enter image description here

I've also tried

mysqli_set_charset($con,"utf8");

but nothing seems to work I've tried a lot of the charset types but still it remains as a ?.

Martin
  • 22,212
  • 11
  • 70
  • 132
bob marley
  • 41
  • 1
  • 1
  • 8

1 Answers1

1

Character setting from MySQL to HTML output is like drinking through a set of very long straws, to get the fine liquid to your mouth, each straw needs to be the correct one, without blockage and without kinks in it.

I highly recommend reading this topic.

To display the data in a MySQL table on a browser with the correct character set you need to:

1) Set the MySQL column Collation as (something like) UTF8mb4.

2) (Also set the MySQL table Collation as (something like) UTF8mb4)

3) Set the MySQL Connection Collation/Charset to UTF8mb4.

4) Set the PHP active charater set to UTF-8 using multbyte strings plugin.

mb_internal_encoding('UTF-8');
// Tell PHP that we'll be outputting UTF-8 to the browser
mb_http_output('UTF-8');

5) Set the HTML character encoding to UTF-8, tyically with a header such as:

header('Content-Type: text/html; charset=utf-8');

Or an HTML Head Meta tag.


As a side note (which will probably fix your issue):

mysqli_set_charset($con,"utf8");

Is the PROCEDURAL way of doing this, but your code looks like you're using Object Orientated MySQLi, so I recommend using:

 $con->set_charset("utf8mb4");

Community
  • 1
  • 1
Martin
  • 22,212
  • 11
  • 70
  • 132