Sql does not recognize the pelica

Asked

Viewed 74 times

0

I have a problem where sql does not recognize the pelica

<div class="col-md-6 form-left">
                    <select name="utilizadores" >
                        <option value="0">Utilziadores ativados</option>
                        <option value="1">utilizadores arquivados</option>
                    </select>
                    <div class="form-inputs name">
                    <p>Pesquisar por nome</p>

                    <input type="text" name="pesnomeuser" placeholder=""  />


                </div>



 if(isset($_POST['procura'])){
            $procura=$_POST['pesnomeuser'];
            $utilizadores=$_POST['utilizadores'];

            $sql=sprintf("select * from users  where  NOMEUSER   like '%s' or USER like '%s' and arquivo='%t' order by NOMEUSER asc;","%".$procura."%","%".$procura."%",$utilizadores);
            $a=mysqli_query($ligacao,$sql);
            ?>
            <table>
            <tr>
            <th>Nome</th>
            <th>Nome de utilizador</th> 
            </tr>
            <?php while ($reg_sql=mysqli_fetch_array($a)){  ?>
            <tr>
            <td><?php echo $reg_sql['NOMEUSER']; ?></td>
            <td><?php echo $reg_sql['USER']; ?></td>
            <td>

            <input type="hidden" name="id" value="<?php echo $id; ?>">
            <a href="utilizadores.php?edit=<?php echo $reg_sql['ID_USER']; ?>" class="edit_btn" >Editar</a>

        </td>
        <td>
        <input type="hidden" name="id" value="<?php echo $id; ?>">
            <a href="utilizadores.php?eliminar=<?php echo $reg_sql['ID_USER']; ?>" class="edit_btn" >Eliminar</a>
        </td>
            </tr>

            <?php }
            ?>
            </table>
        <?php   
        }
  • Which error is shown?

  • Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs company users.php on line 221

  • The name of your field is USER same? then should put it among crases

  • Yes it is, I’ve tried a thousand and one ways and I can’t

  • If you can help me, I’d really appreciate it

  • Leave it at that \USER` like '%s'`

  • remains the same

  • Leave your consul like this: $a=mysqli_query($ligacao,$sql) or die(mysqli_error($ligacao)); see if there are any other errors.

  • now give me this error You have a syntax error in your SQL near '%' or USER like '%'%' and file='' order by USER asc' at line 1

Show 4 more comments
No answers

Browser other questions tagged

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