Accents are not shown [duplicated]

1

I am loading this information from a DB, but when it is displayed in the HTML it does not recognize the accents.

I'm using PDO to connect to the DB and I use UTF-8 in the html

Reviewing phpMyAdmin I see that the coding is as follows.

Could you advise me on how to solve this problem? Thanks.

    
asked by Marcos Rugerio 08.11.2018 в 23:28
source

1 answer

1

Within the declaration of your connection, add one more parameter to indicate that you will use UTF8 so that when you declare it, it will remain as a global attribute for the rest of the operations where you occupy this variable of access to the database

Your code should look like this

$conexion = new PDO('mysql:host=localhost;dbname=agenda;charset=utf8', 'root', '');

Right after: dbname=agenda you indicate that you will use utf8

So that when you execute any SQL statement that occupies $conexion , UTF8 will be applied to the result dataset

    
answered by 08.11.2018 / 23:45
source