PHP site does not read special characters

Asked

Viewed 94 times

1

The Site they sent me (I am an intern) is in trouble because it is not reading the special characters. I’ve noticed the famous charset UTF-8, but when I went to look at the databank, the collation is "latin1_swedish_ci".

This may be the reason ? I’ve heard that if you change it won’t read again, you have to rewrite everything, it’s true ?

  • The default character of the site should be the same as the database if you do not continue to have problems with accentuation but there are some commands to suit the character and you can also treat the output character in the database connection say which is the charset of your html/php

2 answers

-2

When creating the database did you set to UTF8 or left the default? Do a test and perform this change in the database (localhost and backup pfv kk)

ALTER DATABASE nameBD CHARACTER SET utf8 COLLATE utf8_general_ci;

Or create a bank again as utf8 and make the import. You can also, if you prefer of course, just do the accentuation treatment on the output.

-2

The charset that you verified is in the instantiation class of the connection?

Check it out, there’s got to be something like the code below:

$con = new PDO("mysql:host=localhost;dbname=forum;**charset=utf8**", "root", "root");
  • 1

    How did you come to the conclusion that he uses PDO in connection?!

Browser other questions tagged

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