Problems with accentuation

Asked

Viewed 190 times

0

I have visited several sites and Stackoverflow was the main one, where several solutions were proposed to problems of accentuation in the pages. I realized that I had set up my database wrong (utf8-bin) and my page was charset ISO-8859-1. I fixed and tried everything but my header keeps displaying strange characters like the below:

inserir a descrição da imagem aqui

My headline is like this:

<?php
        $title = BD::conn()->prepare("SELECT `title`, `id`, `keywords`, `description` FROM `pags` WHERE `id` = ? LIMIT 0 , 1");
        $title->execute(array($pag));
        $dados = $title->fetch();
?>

<!doctype html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title><?php echo $dados['title']; ?> - Gopinatha &reg;</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />

My bank is like this:

inserir a descrição da imagem aqui

My table is like this:

inserir a descrição da imagem aqui

And the field in question is like this:

inserir a descrição da imagem aqui

  • How are you making the connection to the bank ?

  • Hello Raoni, I will edit the post to put the connection too

2 answers

1

Try to place a header before your html, like this:

<?php
       header("Content-type: text/html; charset=utf-8");
       setlocale(LC_TIME, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
       date_default_timezone_set('America/Sao_Paulo');
?>

    <!doctype html>
    <html lang="pt-br">
    <head>
    <meta charset="utf-8">
    <title><?php echo $dados['title']; ?> - Gopinatha &reg;</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  • Thank you for the reply Victor, but it also did not work...

  • Removes this goal: <meta http-equiv="content-type" content="text/html;charset=utf-8" /> and "<meta charset="utf-8">" replaces it with "<meta charset="UTF-8">"

  • It didn’t work either. :/

0


The problem is that the database does not allow accentuation but allows special characters to replace them.

Recommend this site. In the top box type the database text, then convert and paste into the database and it will be right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.