Acentuação em banco de dados / PHP x Harbour
Moderador: Moderadores
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Acentuação em banco de dados / PHP x Harbour
Pois é, só pra lembrar.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Acentuação em banco de dados / PHP x Harbour
Sim, vc disse.
Só que eu não sabia como fazer isso.
Mas que bom que o Vlademiro sabe.
Só que eu não sabia como fazer isso.
Mas que bom que o Vlademiro sabe.
Inacio de Carvalho Neto
Acentuação em banco de dados / PHP x Harbour
Estou tentando adaptar as demais páginas, mas encontrei problemas em algumas.
Veja esta, por exemplo:
A função conectk está assim:
Veja nos anexos como está aparecendo a tabela no Heidisql e como aparece na consulta deste php.
O collation da tabela parece estar correto:
Veja esta, por exemplo:
Código: Selecionar todos
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Tony Moreira de Araujo">
<title>Bíblia</title>
<!-- Bootstrap core CSS -->
<link href="/site/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="/site/css/style.css" rel="stylesheet">
</head>
<body>
<main>
<?php
echo "<font size='2'>";
include("conexao.php");
conectk("","");
$sql = "SELECT biblia,paginas,leitura,parei,data,qual FROM leiturabiblica WHERE id<=4";
$rs=mysql_query($sql);
if (!$rs)
{
exit("Error in SQL: ".$sql);
}
$nrec = mysql_num_rows($rs); //total de registros
if($nrec>0)
{
echo "<table>";
echo '<table Border="1"><tr>';
// echo '<font size="1">';
?>
<style>
table, th, td
{
border:2px solid black;
}
</style>
<?php
echo "<th>Bíblia</th>";
echo "<th>Páginas</th>";
echo "<th>Leitura</th>";
echo "<th>Parei</th>";
echo "</tr>";
$i=1;
while ($l = mysql_fetch_array($rs))
{
echo "<tr>";
echo '<font size="2">';
echo "<th><p align='Left'>".utf8_encode($l['biblia'])."</p></th>";
echo "<th><p align='Left'>".utf8_encode($l['paginas'])."</p></th>";
echo "<th><p align='Left'>".utf8_encode($l['leitura'])."</p></th>";
echo "<th><p align='Left'>".utf8_encode($l['parei'])."</p></th>";
// echo "<th><p align='Left'>".utf8_encode(substr($l['assunto'],0,28))."</p></th>";
echo "</tr>";
$i++;
}
echo "<table>";
echo '<table Border="1"><tr>';
// echo '<font size="2">';
?>
<style>
table, th, td
{
border:2px solid black;
}
</style>
<?php
$sql = "SELECT biblia,paginas,leitura,parei,data,qual FROM leiturabiblica WHERE data>'".(date('H')-3)."'";
$rs=mysql_query($sql);
if (!$rs)
{
exit("Error in SQL: ".$sql);
}
echo "<tr>";
echo "<th>Data</th>";
echo "<th>Qual</th>";
echo "</tr>";
$i=5;
while ($l = mysql_fetch_array($rs))
{
echo "<tr>";
echo '<font size="1">';
echo "<th><p align='Left'>".$l['data']."</p></th>";
echo "<th><p align='Left'>".utf8_encode($l['qual'])."</p></th>";
// echo "<th><p align='Left'>".utf8_encode(substr($l['assunto'],0,28))."</p></th>";
echo "</tr>";
$i++;
}
echo "</table>";
}
echo '<a href="biblia2.php" class="btn btn-primary btn-lg col-5 col-xs-5 col-sm-5 col-md-5 col-lg-5 col-xl-5 align-self-center d-flex flex-column justify-content-center align-items-center line-6">Alterar Bíblia</a>';
?>
</div>
</div>
</div>
</main>
<script src="./bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>A função conectk está assim:
Código: Selecionar todos
function conectk()
{
$dthj=date('Y-m-d');
$banco = "xxx";
$usuario = "xxx";
$senha = "xxx";
$hostname = "mysql.xxx.com.br";
$conn = mysql_connect($hostname,$usuario,$senha);
mysql_set_charset("UTF8", $conn);
if (!$conn)
{
echo "<br>";
echo "Não conectou";
}
$sel=mysql_select_db($banco,$conn);
if (!sel)
{
echo "Não foi possível abrir o banco de dados";
echo 'MySQL Error: ' . mysql_error();
exit;
}
} O collation da tabela parece estar correto:
Será que ainda estou fazendo algo errado?CREATE TABLE `leiturabiblica` (
`Biblia` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`paginas` CHAR(25) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`leitura` CHAR(30) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`parei` CHAR(30) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`data` DATE NULL DEFAULT NULL,
`qual` CHAR(16) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`id` INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`) USING BTREE
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=14
;
Inacio de Carvalho Neto
Acentuação em banco de dados / PHP x Harbour
Não é necessário usar a função utf8_encode porque o dado já está em utf8.
Acentuação em banco de dados / PHP x Harbour
Verdade. Tinha esquecido deste detalhe.
Tirei e resolveu.
Muito obrigado.
Tirei e resolveu.
Muito obrigado.
Inacio de Carvalho Neto

