Returns the symbol in an accented letter of the database

Asked

Viewed 47 times

-2

The user searches for a name on the page, more precisely in a modal, when the name is returned it will appear this symbol: (if it has an accent). But in the database the name is accentuated. Below is the code that makes the request in the database and returns the name:

<?php
include("banco.php");
@$nome = $_POST["nome_aluno_busca"];
$sql = "SELECT codigo, nome FROM Aluno where nome like '%$nome%' order by nome;";
$result = mysql_query($sql, $conexao) or die (mysql_error());
$i = "0";
$i = mysql_num_rows($result);
echo "<div id=lista align=center>";
if ($i>0){
while ($linha = mysql_fetch_array ($result)) {
$codigo = $linha["codigo"];
$nome_aluno = $linha["nome"];
echo "<font color='red'><b>$codigo</b></font> - $nome_aluno<br><hr>";
}
}
echo "</div>";
?>

2 answers

-2

Try using the following code block before printing the String

utf8_encode($variavel_contendo_string)

-2

Normalize your database to UTF8.

Browser other questions tagged

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