On this page I select the book id to display it and then refresh the visits field by incrementing it.
<?php
if(isset($_GET['id']))
{
$id = $_GET['id'];
}
$livros = mysqli_query($conexao, "SELECT nome, descricao, imagem, download,
visitas FROM livro WHERE id='$id'")or die(mysqli_error($conexao));
if(mysqli_num_rows($livros) <= 0)
{
echo "<h2>Banco de dados não retornou nenhum valor</h2>";
}
while($res_livros = mysqli_fetch_array($livros))
{
$nome = $res_livros['0'];
$descricao = $res_livros['1'];
$imagem = $res_livros['2'];
$download = $res_livros['3'];
$visitas = $res_livros['4'];
}
?>
<h1><?=$nome;?></h1>
<a data-fancybox="gallery" href="uploads/livros/<?=$imagem;?>">
<figure>
<img class="alignright" width="200" src="uploads/livros/<?=$imagem;?>"/>
<figcaption><a id="download" href="<?=$download?>">Download</a>
</figcaption>
</figure>
</a>
<h3><?=$descricao?></h3>
</section>
</div>
<?php
if(isset($visitas))
{
$add_visitas = $visitas + 1;
$up_visitas = mysqli_query($conexao, "UPDATE livro SET visitas =
'$add_visitas' WHERE id='$id'")or die(mysqli_error($conexao));
}
?>
To post the whole code but the error happens is down here in the UPDATE book.
Now, I decided to print the id here below and the id of the book + ". php" appeared like this: 106.php. That's why Boolean is giving, but where does this ".php" come from? In the database is just the normal number.
I solved the problem here, it was bullshit of me, obviously I passed the .php along with the id to the page but for some reason SELECT had no conflict with that, but UPDATE did.