0
When upling the database appears 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 connect? because local 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>';
?>
Your connection is not valid, second error.
– rray