query error in mysqli

2

Person, as I tidy this my code, it is giving error:

<?php
//IMPRIME TODOS OS VALORES DO BANCO CADASTRO

$servidor = "localhost";
$usuario  = "root";
$senha    = "admin";
$banco    = "cadastro";

//conecta-se ao banco de dados Mysql
$con = new mysqli($servidor, $usuario, $senha, $banco) or die("<script     language='javascript'>alert('Unable to connect to database')</script>"); 

// Verifica se ocorreu algum erro
if (mysqli_connect_errno()) {
die('Não foi possível conectar-se ao banco de dados: ' . mysqli_connect_error());
exit();
}
if(isset($_POST['buscar'])){
$q = mysql_real_escape_string($_POST['consulta']);
$query_Busca = "SELECT * FROM 'equipamento' WHERE 'tombamento' LIKE '%$q%'";
$Busca = $con->query($query_Busca);
$row_Busca = mysqli_fetch_array($Busca);
$totalRows_Busca = $Busca->num_rows;

} else {
$query_Busca = "SELECT * FROM 'equipamento'";
$Busca = $con->query($query_Busca);
$row_Busca = mysqli_fetch_array($Busca);
if (!$check1_res) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
$totalRows_Busca = $Busca->num_rows;
}
?> 

The errors I get are: mysqli_fetch_array () expects parameter 1 to be mysqli_result, boolean given IT'S THIS ONE: Undefined variable: check1_res in C: \ wamp \ www \ register \ query.php on line 58

    
asked by anonymous 02.08.2014 / 23:42

1 answer

1

When you make a query and table / field have special characters use:

'

Simple quotation marks ' should only be used in values of type text / character etc

Change the occurrences:

$query_Busca = "SELECT * FROM 'equipamento'";

by:

$query_Busca = "SELECT * FROM 'equipamento'";

or:

$query_Busca = "SELECT * FROM equipamento";

When executing a query, remember to make it display the database error like this:

$Busca = $con->query($query_Busca) or die($con->error);
    
03.08.2014 / 00:17