bonsoir,
je voudrais utiliser l'encodage utf8 au moment où je fais la requête sql, avec SET NAMES utf8 et SET CHARACTER SET utf8 mais ça marche pas, les caractères de ma base (encodée en utf8) ne s'affichent pas.
j'ai fait une erreur dans mon code??
merci
je voudrais utiliser l'encodage utf8 au moment où je fais la requête sql, avec SET NAMES utf8 et SET CHARACTER SET utf8 mais ça marche pas, les caractères de ma base (encodée en utf8) ne s'affichent pas.
j'ai fait une erreur dans mon code??
merci
<?php
$host = 'localhost';
$db = 'carbase';
$user = 'root';
$pwd = '';
try
{
$connexion = new PDO("mysql:host=$host;dbname=$db", $user, $pwd);
}
catch(Exception $e)
{
echo 'Erreur : ' . $e->getMessage(). '<br />';
echo 'N° : ' . $e->getCode();
die();
}
$resultats = $connexion->query("SELECT * from vehicules");
$connexion->query("SET NAMES utf8");
$connexion->query("SET CHARACTER SET utf8");
$resultats->setFetchMode(PDO::FETCH_OBJ);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document sans nom</title>
</head>
<?php
while($ligne = $resultats->fetch() )
{ ?>
<p><?php echo 'Observations : ' . $ligne->observations; ?></p>
<?php }
$resultats->closeCursor();
?>
<body>
</body>
</html>