0
I’m having difficulty connecting twice in my database, each time will connect to a table the code and the following:
Categories
<!-- Portfolio Grid -->
<section class="bg-light" id="portfolio">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Categorias</h2>
<h3 class="section-subheading text-muted"></h3>
</div>
</div>
<div class="row">
<?php
require_once "conecta_db.php"; //CHAMA O ARQUIVO DE CONEXÃO COM BD
$tb = "categorias";
$sql = "SELECT * FROM ".$tb;
$result=mysqli_query($con,$sql);
while($linha = mysqli_fetch_assoc($result))
{
?>
<div class="col-md-4 col-sm-6 portfolio-item">
<a class="portfolio-link" href="<?php echo "categorias.php?idcat=".$linha["idcat"];?>">
<div class="portfolio-hover">
<div class="portfolio-hover-content">
<i class="fa fa-plus fa-3x"></i>
</div>
</div>
<div class="portfolio-caption">
<h4><?php echo utf8_encode ($linha["nome"]); ?></h4>
<?php echo "<img class=\"img-fluid\" src=\"img/servicos/".$linha["idcat"].".png\">"; ?>
<p class="text-muted"><?php echo utf8_encode ($linha["descricao"]);?></p>
</div>
</a>
</div>
<?php } // fecha while
// Free result set
mysqli_free_result($result);
mysqli_close($con);
?>
</div>
</div>
</section>
<section class="bg-light" id="servicos">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Serviços</h2>
<h3 class="section-subheading text-muted"></h3>
</div>
</div>
<div class="row">
<?php
require_once "conecta_db.php"; //CHAMA O ARQUIVO DE CONEXÃO COM BD
$tbb = "servicos";
$sqll = "SELECT * FROM ".$tb;
$resultt=mysqli_query($con,$sql);
while($linha = mysqli_fetch_assoc($resultt))
{
?>
<div class="col-md-4 col-sm-6 portfolio-item">
<a class="portfolio-link" href="<?php echo "categorias.php?idcat=".$linha["idsv"];?>">
<div class="portfolio-hover">
<div class="portfolio-hover-content">
<i class="fa fa-plus fa-3x"></i>
</div>
</div>
<div class="portfolio-caption">
<h4><?php echo utf8_encode ($linha["nome"]); ?></h4>
<?php echo "<img class=\"img-fluid\" src=\"img/sv/".$linha["idsv"].".png\">"; ?>
<p class="text-muted"><?php echo utf8_encode ($linha["descricao"]);?></p>
</div>
</a>
</div>
<?php } // fecha while
// Free result set
mysqli_free_result($result);
mysqli_close($con);
?>
</div>
</div>
</section>
What error is being shown?
– Andrei Coelho
Warning : mysqli_query(): Couldn’t fetch mysqli in C: xampp htdocs tcc startbootstrap-Agency-Gh-pages index.php on line 167 Warning : mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, null Given in C: xampp htdocs tcc startbootstrap-strapAgency-Gh-pages index.php on line 169 Warning : mysqli_free_result(): Couldn’t fetch mysqli_result in C: xampp htdocs tcc startbootstrap-Agency-Gh-pages index.php on line Warning : mysqli_close(): Couldn’t fetch mysqli in C: xampp htdocs tcc startbootstrap-Agency-Gh-pages index.php on line 194
– Daniel Henrique