0
All right, guys? Guys, I’m having a problem that I haven’t had before. I wrote the code below and at the time of opening the page by localhost in the browser it returns the following error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in C: xampp htdocs site_almoxarifado_testes controle_material.php on line 1
Stock Control
<body id="corpo">
    <header id="cabecalho">
    </header>
    <section id="titulo_principal">
        <form method="post" action="funcoes.php">
            <input type="text" name="pesquisar" size="126" placeholder=" exp: cabo 4mm ...">
            <input type="submit" value="Buscar">
        </form>
        <nav id="menuTabela">
            <ul type="disc">
                <li><a class="tabela" href="controle_material.php">Id's das Cidades</a></li>
                <li><a class="tabela" href="controle_notas.php">Nome das Cidades</a></li>
                <li><a class="tabela" href="saida_material.php">Estados</a></li>
            </ul>
        </nav>
        <div id="principal">
            <table id="tabela2">
                <?php if (isset($pesquisar)) {
                    while ($rows_cursos = $resultado_busca->fetch_assoc($resultado_busca)) {
                        echo utf8_encode($rows_cursos['nome_cidade']);
                    }
                } else { while ($colunas = $selecao_geral->fetch_assoc()) {?>
                        <tr>
                            <td id="td"><?php echo utf8_encode($colunas['idcidade']); ?></td>
                            <td id="td1"><?php echo utf8_encode($colunas['nome_cidade']); ?></td>
                            <td id="td2"><?php echo utf8_encode($colunas['uf']); ?></td>
                        </tr>
                    <?php }
                 } ?>
            </table>
        </div>
    </section>
    <aside>
    </aside>
    <footer id="rodape">
    </footer>
    <?php $conecta->close(); ?>
</body>
This is the code for.php functions
include 'controle_material.php';
define("SERVIDOR", "localhost");
define("USUARIO", "root");
define("SENHA", "");
define("BANCODEDADOS", "controle_almoxarifado");
$conecta = new mysqli(SERVIDOR, USUARIO, SENHA, BANCODEDADOS);
if ($conecta->connect_error) {
    trigger_error("ERRO NA CONEXÃO: " . $conecta->connect_error, E_USER_ERROR);
}
$pesquisar = $_POST['pesquisar'];
//$pesquisa_tabela = mysqli_query($conecta, 'select * from cidade where nomes like %pedro%');
$selecao_geral = mysqli_query($conecta, "select * from cidade");
$resultado_busca = mysqli_query($conecta, "select * from cidade where nome_cidade like %$pesquisar%");
?>
Oops! It did not solve, but I saw the reason for the excess memory used. Searching to solve, I was able to load the page, and when the page appeared she was opening several times the same table repeatedly within the same page like a loop.
– Jonas Soares