0

I keep on getting this errors and i cant seem to find a solution:

Warning: Trying to access array offset on value of type bool in /opt/lampp/htdocs/shop/app/models/category.class.php on line 87

<?php
public function get_one($id){

$id = (int)$id;

$DB = Database::newInstance();
$data = $DB->read("select * from categories where id = '$id' limit 1");

return $data[0];

} 
?>

This is line 87

return $data[0];
Userpf
  • 5
  • 3
  • What does `var_dump($data);` show before that line? – Darren Aug 20 '21 at 00:38
  • The var_dump function showed the following - array(1) { [0]=> object(stdClass)#29 (3) { ["id"]=> string(2) "16" ["category"]=> string(3) "Aaa" ["disabled"]=> string(1) "0" } } bool(false) – Userpf Aug 22 '21 at 18:57

0 Answers0