0

here is my problem, i got a website that displays the reviews from customers from my database (clearDB) in the table 'avis' but when i open my heroku-app all the letters with accent are changed by '?'... enter image description here It seems that the problem comes from the database because my html pages display well the letters with accent. So i checked ma table 'avis' and encode is utf8_general_ci, here's a pic enter image description here And here is my index.php code that gets the queries to database:

<head>
<meta charset="UTF-8" />
...
</head>
...
<?php
              // Connexion à la base de données
              $servername = "............";
              $username = "............";
              $password = "............";
              $dbname = "................";

              try {
                $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
                $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

                // Récupérer les avis approuvés de la table "avis"
                $stmt = $conn->prepare("SELECT * FROM avis WHERE approuve = :approuve");
                $approuve = 1; // Seuls les avis approuvés
                $stmt->bindParam(':approuve', $approuve);
                $stmt->execute();

                if ($stmt->rowCount() > 0) {
                  while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                    $nom = $row['nom'];
                    $commentaire = $row['commentaire'];
                    $note = $row['note'];

                    // Afficher les informations de l'avis
                    echo "<div class='avis mx-5 my-3'>";

                    // Générer les étoiles en fonction de la note
                    for ($i = 1; $i <= $note; $i++) {
                      echo "★";
                    }

                    echo "</p>";
                    echo "<p><i>$commentaire</i></p>";
                    echo "</div>";
                  }
                } else {
                  echo "Aucun avis approuvé pour le moment.";
                }

                // Fermer la connexion à la base de données
                $conn = null;
              } catch (PDOException $e) {
                echo "Échec de la connexion à la base de données : " . $e->getMessage();
              }
              ?>

If someone could help me solve this problem... I just started deploy my website on heroku yesterday and database on clearDB! On localhost using phpmyadmin that was good.

In phpmyadmin i exported my database and imported in heroku database (clearDB) with MySQL Workbench, then i changed the connections to server in all my php pages.

Thanx for helping me!

  • [utf8 all the way](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) all sides need the same character set collation, i believe there must be a lot of threads for that – nbk Jun 20 '23 at 20:49
  • thanx for help :) i check this! – colas vincendon Jun 20 '23 at 20:57

0 Answers0