Acentuação em banco de dados / PHP x Harbour
Enviado: 13 Mai 2023 19:34
Pois é, só pra lembrar.
Em homenagem a Paulo Cesar Toledo
https://pctoledo.org/
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>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;
}
} 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
;