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?
– Don't Panic
Warning: mysqli_fetch_array() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs company users.php on line 221
– André Tavares
The name of your field is
USER
same? then should put it among crases– rray
Yes it is, I’ve tried a thousand and one ways and I can’t
– André Tavares
If you can help me, I’d really appreciate it
– André Tavares
Leave it at that
\
USER` like '%s'`– rray
remains the same
– André Tavares
Leave your consul like this:
$a=mysqli_query($ligacao,$sql) or die(mysqli_error($ligacao));
see if there are any other errors.– rray
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
– André Tavares