1
I have a PHP function using Mysql, follows:
public function listAll(){
$sql = mysqli_query($this->conectar, "SELECT * FROM items");
$this->desconectar;
return $sql->fetch_all();
}
my page for instance:
$p = new Items();
$result = $p->listAll();
$r = new ArrayIterator($result);
print_r($r);
when I give a print_r
in it returns me that
ArrayIterator Object ( [storage:ArrayIterator:private] => Array ( [0] => Array ( [0] => 3 [1] => prod test 3)))
When I try to call the name it returns to me:
echo $r->current()->nome
Trying to get property of non-object in
result of print_r($result)
Array ( [0] => Array ( [0] => 3 [1] => prod test 3)
because it needs a
ArrayIterator
?– rray
gives a
print_r($result)
and ask the question! maybe you don’t even need this Arrayiterator– novic
Try using the MYSQLI_ASSOC parameter within the function
– Felipe
the error is saying that the result is not an object, I believe that because it returns an array of objects
– Costamilam
Felipe I used as rray said but continues the mistake
Trying to get property of non-object
– Antonio Carlos