Good afternoon! I'm listing some mysql data using php; but when displayed in place of words that are accentuated I see characters like these . My schema and table are configured with charset utf8_general_ci . And in my html document where the data returned from the database is being displayed, it has the charset meta tag set to utf-8 .
>This is the function code where I print the query result:
public function showTinyNews() {
include_once 'sys/models/Connection.class.php';
$conn = new Connection();
$execQuery = mysqli_query($conn->connect(), "SELECT * FROM news ORDER BY date DESC");
foreach ($execQuery as $news) {
echo "<li>
<h2><a href='index.php?p=news&id={$news['idnews']}'>{$news['title']}</a>
<span>Por: {$news['author']} ({$news['date']})</span></h2>
<p>{$news['news']}</p>
<a class='leia-mais' a href='index.php?p=news&id={$news['idnews']}'>leia mais</a>
</li>";
}
}
Connection Code
class Connection {
static $host = 'localhost';
static $user = 'root';
static $password = '00';
static $database = 'database';
public function connect(){
$mysqli = new mysqli(self::$host, self::$user, self::$password, self::$database);
if(mysqli_errno($mysqli)){
echo "Failed to connect to database: mysqli_connect_errno()
mysqli_connect_error()";
} else {
return $mysqli;
}
}
}