When the database is loaded, it looks like this:
SQLSTATE [HY000] [2002] Connection timed out Fatal error: Call to a member function prepare () on a non-object in
How can I resolve, to be able to connect? because location works normally.
<?php
require_once ('./funcao/conecta.php');
$conn = conecta();
$sql = $conn->prepare("SELECT * FROM 'lojao'.'categorias' ORDER BY nome_categoria ASC");
$sql->execute();
$sql->setFetchMode(PDO::FETCH_ASSOC);
while ($linha = $sql->fetch()) {
$categoriaid = $linha['id_categoria'];
$nomecategoria = $linha['nome_categoria'];
echo'<div align = "left">';
echo'<li>
<a href = "index.php?idCat=' . $categoriaid . '">' . $nomecategoria . '</a>
</li>';
}
echo '</div>
</div id="link"><div>
</div>';
?>