Error with accented characteristics

Asked

Viewed 40 times

-1

Good afternoon,

The accented characters in my system are not working when I bring it from the database, are like this , I have tried to put the meta tag, I have tried to save the file with a different encoding, but it does not work..

NOTE: the text written by me in the code carries the right, it is only the information that comes from the bank that does not carry

NOTE²: When I run the query in Sqlyog all the accents are there correctly

  • try applying utf8_encode($variable) to the variable that is printed from the database

  • It all depends on which the encoding used in the database, this character appears when you try to print a text that has some encoding other than utf8 in utf-8. The @Anthraxisbr solution should work... But maybe it’s more interesting to change the encoding of the bank or its archive php

  • @Anthraxisbr this function works, but still a more "global" solution Thank you

  • @edsonalves unfortunately have no way to do this, the company’s database has been structured for a while and has several systems that use it. Thank you

1 answer

2


Use your query method to execute the query

SET NAMES (sua codificação de caracteres EX: utf8); <- isto diz para a conecxão com o banco que os caracteres estão em tal codificação

And in php

mb_http_input("mesma codificação de caracteres do banco");
mb_http_output("mesma codificação de caracteres do banco");
mb_regex_encoding("mesma codificação de caracteres do banco");
mb_internal_encoding("mesma codificação de caracteres do banco");

Remembering that these settings can be made in your php.ini , but if the hosting is shared you probably won’t be able to edit it

  • Remembering that these settings must be at the beginning of the codifo execution and right after the opening of the connection with the database

Browser other questions tagged

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