I inserted some data from phpMyAdmin, it seems to be fine on phpMyAdmin image , but when I use PHP output the result from MYSQL, it becomes: image
PHP code:
function showTableRows($db)
{
$sql = "SELECT * FROM forums ORDER BY id";
$stmt = $db->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row)
{
$forum_id = $row['forum_id'];
echo '<tr>';
echo '<td>';
echo '<a href="viewforum.php?forum='. $forum_id .'">'. $row['name'] .'</a>';
echo '<br>';
echo '<small>'. $row['description'] .'</small>';
......
MYSQL collation already set to utf8_general_ci
HTML charset already set to utf-8
What am I missing??
This can be because you are missing the charset option when connecting:
example: $dbh = new PDO('mysql:host=localhost;dbname=test;charset=utf-8', etc...
I don't see the connection line in your code, so, I can't know for sure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.