Query error Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given in

Asked

Viewed 122 times

-2

I created a project in XAMPP where it is working perfectly. But when hosting on 000webhost, it emits this error.

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
/storage/ssd4/099/13917099/public_html/rel/rel_servico.php on line 18

This is my code:

$id = $_GET['id'];
include('../conexao.php');
$query = "select o.id, o.cliente, o.motorista, o.placa, o.servico, o.dtabertura, o.status,
       c.nome, c.cnpj, c.estadual, c.social, c.telefone, c.email
        from orcamentos as o 
       INNER JOIN 
       clientes as c 
     on o.cliente = c.nome
      where o.id = '$id'";
$result = mysqli_query($conexao, $query);

while ($res_1 = mysqli_fetch_array($result)){  //Aqui onde emite o erro.
    $dtabertura2 = implode('/', array_reverse(explode('-', $res_1["dtabertura"])));
    $servico2 = implode('<hr>', (explode(';', $res_1["servico"])));
?>
<div class="cabecalho">
    <div class="row">
        <div class="col-sm-4">  
          <img id="logo" src="../img/logo_origin.fw.png" width="270px">
        </div>
        <div class="col-sm-8">
            <h3 class="titulo"><b>WP DA SILVA - ME</b></h3> 
            <table>
            <tr>
                <th class="cabecath"> CNPJ: 09.500.074/0001-61 </th>
                <th class="cabecath"> IE: 06.362337-4 </th>
            </tr>
            <tr>
                <td class="cabecath"> Rua Josias Inojosa de Oliveira, 5500 </td>
                <td class="cabecath"> Juazeiro do Norte - Ceará </td>
            </tr>
            <tr>
                <td class="cabecath"> Bairro: Santa Rosa </td>
                <td class="cabecath"> CEP: 63045-010 </td>
            </tr>
            <tr>
                <td class="cabecath"> Distrito Industrial do Cariri </td>
                <td class="cabecath">Tele-vendas: (88) 99901-9397 </td>
            </tr>
            <tr>
                <td class="cabecath">Contato: (88) 98826-1075 </td>
                <td class="cabecath"> E-mail: [email protected] </td>
            </tr>
            </table>
        </div>
    </div>
    </div >
    <br>
    <div class="container">
        <div class="row">
            <div class="col-sm-8">
                <big>Orçamento N° <?php echo $id ?></big>
            </div>
            <div class="col-sm-4">
                <big>DATA: <?php echo $dtabertura2 ?></big>
            </div>
        </div>
    </div>
    <hr>
        <div class="row">
            <div class="col-sm-6">
                <p class="pdefine"><b>Nome do Cliente: </b><?php echo $res_1["cliente"]; ?></p>
            </div>
            <div class="col-sm-6">
                <p class="pdefine"><b>CNPJ/CPF: </b><?php echo $res_1["cnpj"]; ?></p>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <p class="pdefine"><b>R. Social: </b><?php echo $res_1["social"]; ?></p>
            </div>
            <div class="col-sm-6">
                <p class="pdefine"><b>I. Estadual: </b><?php echo $res_1["estadual"]; ?></p>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <p class="pdefine"><b>Motorista: </b><?php echo $res_1["motorista"]; ?></p>
            </div>
            <div class="col-sm-6">
                <p class="pdefine"><b>Telefone: </b><?php echo $res_1["telefone"]; ?></p>
            </div>
        </div>
        <hr>
        <div class="row">
            <div class="col-sm-12">
                <p class="porcamentos"><b> Serviços da placa: <?php echo $res_1["placa"]; ?> </b></p>
            </div>
        </div>
        <table class="table table-bordered">
            <thead>
                <tr>
                <th scope="col" >Serviços a Prestar</th>
                <th scope="col"></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <br>
                    <td scope="row" colspan="2"><br><?php echo $servico2; ?></td>
                </tr>
                <tr>
                    <th scope="row"></th>
                    <th scope="col">Status: <?php echo $res_1["status"]; ?></th>
                </tr>
            </tbody>
            </table>
    <div class="footer">      
    </div>
</div>

<?php } ?>

1 answer

0

The problem may be in connection with the bank. Checks if the access data is correct. (Do not post the access data here so that no one takes advantage of it).

After you check, use a var_dump($result) to see what this variable is returning.

Another tip. Put this at the beginning of your code so that it does not break if there is no id parameter in the query string:

if(!empty($_GET('id')) {
 //Todo o resto do código aqui
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.