-3
I would like to pass the variable value $var
into select, but gives the following error :
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\APOLLO\empresas.php on line 7
Follow the code below:
$var = $_POST['empresa'];
include 'php/db_connect.php';
$result_usuarios = "SELECT $var FROM usuarios ";
$resultado_usuarios = mysqli_query($connect, $result_usuarios);
while($row_usuario = mysqli_fetch_assoc($resultado_usuarios)){
echo "Categoria: " . $row_usuario['categoria'] . "<br>";
}
Does this Answer your Question? Mysql error "expects Parameter 1 to be Resource, Boolean Given in"
– Arthur Siqueira
Ignoring the fact that your code is susceptible to sql code Injection. what is the result of
echo $var
?– Augusto Vasques