0

I just put online a website that I have been developing and discovered that all my accentuated "e" (the site is in french) appear as question marks. I have done a quick search and added

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

but the error persists.

The text is being loaded from a database and here is a pic of its structure:

enter image description here

The field in question is "description" and as you can see I selected utf8 for its collation. I can't help but notice that down in the table showing row statistics it appears as latin_swedish. Not sure if it has anything to do with it. Thanks for any help.

Code that selects the description:

<?php include 'db_connect.php';
$modelID = mysqli_real_escape_string($connect,$_GET['m']); // Model ID, passed through URL

$query = mysqli_query($connect,"SELECT * FROM models WHERE id = ".$modelID);
if (mysqli_num_rows($query)==0) echo "Nothing found.<br/>";
while ($q = mysqli_fetch_array($query)) {
  $picMain = $q['picture_url'];
  $description = $q['description'];
  $picDir = $q['picDir'];
}

// Create an array of images to pass to jQuery
$diaporama = array();
if ($handle = opendir('Images/'.$picDir)) {
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && $entry != ".DS_Store") {
            array_push($diaporama,$entry);
        }
    }
closedir($handle);
}

$randomPicID = array_rand($diaporama,1);
$randomPic = $picDir.$diaporama[$randomPicID];

$substring = substr($randomPic, 0, -5);



 ?>
 <script type="text/javascript" src="JavaScript/general.js"></script>

<div id="GuitarBigWindow">

  <div id="leftWindow" style="background-image: url('Images/<?php echo $picMain; ?>'); ">
    <a href="notalink.html" id="infoButton">+ Information</a>
    <div id="info" class="notVisible"><?php echo $description; ?></div>
  </div>

  <div id="rightWindow" style="background-image: url('Images/<?php echo $randomPic; ?>');"


  onclick="

    var enable = function() { counter++;

    if (counter > 7) {counter = 1;}

    $( '#rightWindow' ).css('background-image', 'url(Images/<?php

      echo $substring;

     ?>' + counter + '.jpg)');}

    enable();

    this.style.pointerEvents = 'none';

    $( '#rightWindow' ).on('transitionend',
        function(e) {

        this.style.pointerEvents = 'auto';

      });

    clearInterval(interval);
    automatic();


   "></div>
Johannes
  • 64,305
  • 18
  • 73
  • 130
Paul
  • 1,277
  • 5
  • 28
  • 56

2 Answers2

0

In general there are just few possible reasons:

  1. font you use does not provide with character needed(almost impossible in your case; also it would be rendered as an empty rectangular)
  2. page uses wrong encoding (you have correct set)
  3. db breaks data trying to store character into wrong character set (you demonstrate it's not a case)
  4. character set for connection is invalid (search for SET NAMES ... - it set 3 different things at once)
  5. data in DB is already broken (it's easy to check)
skyboyer
  • 22,209
  • 7
  • 57
  • 64
0

After establishing the DB connection, try to add

$db_connection->set_charset("utf8");

(where $db_connection stands for your connection)

Johannes
  • 64,305
  • 18
  • 73
  • 130