1

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??

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
user3030712
  • 27
  • 2
  • 6

1 Answers1

1

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.

Denis Leger
  • 213
  • 2
  • 7