0
I’m making a mistake, and I don’t understand why. The mistake:
Fatal error: Call to a member function fetch_assoc() on boolean
the excerpt from the error:
require 'conecta.php';
$sql = "SELECT `nomep`, `endereco` FROM `cadastropn` WHERE `cidade` = Caxias do Sul";
$result = mysqli_query($mysqli, $sql);
while($linha = $result->fetch_assoc()) {
echo '<article>' . $linha['nomep'];
$nome = $linha['nomep'];
echo '</article>';
}
The strange thing is that the mistake only happens when I put the WHERE
city= Caxias do Sul";
Ahh, yes now I’ve seen the bug and already corrected. Thank you friend!
– Nicolas S.
A
if( !$result ) die( mysqly_error( $mysqli ) );
is sufficient to test for errors, but does not use the code in production. More details here: http://answall.com/a/141797/70– Bacco