When requesting information from my bank that contains special characters I get " " but in phpmyadmin in grouping is "UTF-8" and my site also has the UTF-8 goal what can I do to return the correct one?
When requesting information from my bank that contains special characters I get " " but in phpmyadmin in grouping is "UTF-8" and my site also has the UTF-8 goal what can I do to return the correct one?
One suggestion is to convert all input into the database into html entities, as follows the php code:
$email = addslashes(htmlentities($_POST['email'], ENT_QUOTES,'UTF-8'));
In this way, all special characters are converted, and at the time of displaying them, the browser itself will interpret it.
It will be converted according to the table available at linká = á (& aacute)
ã = ã (& atilde)
and so on
I do not know if it's the ideal, but you can query it that way too
$sql = "SELECT * FROM tbl_produto WHERE nome_produto = :nome_produto collate utf8_unicode_ci ";
If you are using PDO add this line:
$pdo -> exec("SET CHARACTER SET utf8");
If you are using mysqli, use the mysqli_set_charset ($ connection, "utf8") function. This function defines the default character set to send and receive data to the Database. If you are using PDO and PHP above version 5.3.6 you can specify the character set in the DSN.
$dsn = sprintf("mysql:host=%s;dbname=%s;charset=utf8", $host, $dbname);
$connection = new \PDO($dsn, $user, $password);
Or (For versions of PHP prior to 5.3.6)
$dsn = sprintf("mysql:host=%s;dbname=%s", $this->host, $this->dbname);
$connection = new \PDO($dsn, $this->user, $this->password);
$connection->exec('SET names = utf-8');