-3
I have the following code:
$escolha = $_POST['unidade'];
if($escolha == 'ut')
{
$conn = new mysqli($host1, $user, $pass, $bd);
if (mysqli_connect_errno()) {
die(mysqli_connect_error());
exit();
}else{
$consulta = $conn->query("SELECT nm_usu FROM usuarios;");
while ($resultado = $consulta->fetch()) {
echo "Nome: {$resultado['nm_usu']}<br/>";
}
}
}
And I’m making the following mistake:
Fatal error: Call to Undefined method mysqli_result::fetch() in
From what I’ve seen it’s not much different from examples that other sites, but what really can it be? Or what’s the best way to do it?
you are using PDO or mysqli ?
– rray
I don’t understand, you quote
PDOin the question but usesMySQLithroughout the code. The error message seems to me self-explanatory, the variable$consultais an instance of the class mysqli_result and it does not have a method calledfetch. Better organize your question so we can help you.– Cahe