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 '?'...
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
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!