0
What is wrong?
I did everything right, researched and resumed the mistake:
Notice: Trying to get property 'num_rows' of non-object in C:\xampp\htdocs\tipo\consulta-online.php on line 21
What can it be?
<?php
$servidorBanco = "localhost";
$usuarioBanco = "root";
$senhaBanco = "12345";
$dadosBanco = "bancodedados";
$conexao = mysqli_connect($servidorBanco, $usuarioBanco, $senhaBanco, $dadosBanco);
if(!$conexao){
die("Falha na conexao: " . mysqli_connect_error());
}else{
//echo "Conexao realizada com sucesso";
}
$sql = "SELECT * FROM sis_clientes";
$result = $conexao->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
//É isso que eu quero que consulta, quero que consulte
//todos os dados refere a esse campo da tabela "login"
echo $row["login"];
}
} else {
echo "0 results";
}
$conexao->close();
?>
Check if the table actually exists. If it exists, add a
die($conexao->error);
after$conexao->query
.– Valdeir Psr
Gave this error. Parse error: syntax error, Unexpected 'die' (T_EXIT) in C: xampp htdocs query-online.php on line 17
– Wesley Rodrigues
i did so. $result = $connected->query($sql) die($connected->error);
– Wesley Rodrigues
And tbm tried so. $result = $connected->query($sql); $result = $connected->error; Also no results.
– Wesley Rodrigues
Missed the or. The correct is
$result = $conexao->query($sql) or die($conexao->error);
– Valdeir Psr
Show amigo, that was it. Problem was that in the database name was sis_clientes and was sis_cliente, thanks. My vote is yours. Put your answer I will add the vote as completed.
– Wesley Rodrigues