Problems in accent display with htmlspecialchars

Asked

Viewed 320 times

0

<?php echo htmlspecialchars ( $exibe_nome [ "nome" ] , ENT_QUOTES , 'UTF-8' ) ; ?>

Words that exist in my database with example accent ( No ) are not displayed in my echo if I remove htmlcharspecials they appear.

How can I solve this problem ?

  • 1

    What encoding of your database?

  • 1

    utf8 encoding <

1 answer

1


Well I’ll try to explain in parts I think so if you go all the way.

First check in the database a COLLATE that has and changes if not for utf8_unicode_ci and the data table.

In the database connection script you put this

header('Content-Type: text/html; charset=utf-8');
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');

And on the page CHARSET that you are the user

<meta http-equiv="content-type" content="text/html;charset=utf-8" />

That done I think you have no problems with accents, I have always done so and never had problems with coding.

  • 1

    I don’t understand why it worked more now I want to find out HAHAHA thank you so much!

  • 1

    It was mysql_query("SET NAMES 'utf8'"); which made it work together with the meta

  • mysql_query("SET NAMES 'utf8'"); arrow that the database encoding and utf8_encode and the meta arrow on the page that are using utf8 so the system always uses the same encoding you were not working because you should not be setting that the data that well from the database are utf8_encode hope to have explained its doubts and the system had no way of knowing which characters are those

Browser other questions tagged

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