Characters that do not display correctly on the UTF-8 website

I did everything I could, but special characters do not display correctly on this web page.

For example, in a database, this is:

enter image description here

But on the site it is:

Nouveaux R alistes 

Here everything that I checked ...

The database is set to UTF-8:

enter image description here

The page was written in NetBeans, with the document encoding set to UTF-8:

enter image description here

The page title declares UTF-8:

enter image description here

The meta encoding is set to UTF-8:

enter image description here

I even added the following line to my .htacess:

enter image description here

But the characters are still not displayed correctly, and I get the following error from the W3C Validator:

enter image description here

It seems to me that I tried everything, but it still won’t work. (I even tried htmlspecialchars and htmlentities in PHP, but the page doesn't even display!)


UPDATE
As requested, here is the code I'm using:

 class Exhibition { public $exhibitionDetails; public function __construct(Database $db, $exhibitionID){ $this->_db = $db; $params['ExhibitionID'] = $exhibitionID; $STH = $this->_db->prepare("SELECT * FROM Exhibition INNER JOIN Schedule ON Exhibition.ExhibitionID = Schedule.ExhibitionID WHERE Schedule.Visible = 1 AND Exhibition.ExhibitionID = :ExhibitionID;"); $STH->execute($params); $this->exhibitionDetails = $STH->fetchAll(PDO::FETCH_ASSOC); } } 

A...

 try { $db = new Database(SITE_ROOT."/../"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $exhibition = new Exhibition($db,$_GET['id']); } catch (PDOException $e) { echo "<p class='error'>ERROR: ".$e->getMessage()."</p>"; } 

And finally ...

 <p><?php echo $exhibition->exhibitionDetails[0]["Desc"]; ?></p> 
+4
source share
2 answers

If you use mysql_* functions:

 mysql_query("SET NAMES 'utf8'"); 

If you are using PDO

 $dsn = 'mysql:host=localhost;dbname=testdb'; $username = 'username'; $password = 'password'; $options = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); $dbh = new PDO($dsn, $username, $password, $options); 

It sets the encoding of the connection.

+2
source

It has been several years since I used PHP, but then it did not support Unicode, and a quick google search tells me that it still does not work. You can still make it work.

Here's a great link:

Encodings and character sets for working with text

+1
source

All Articles