Hey guys and gals,
I am getting a property of non object and i can not figure out why.
Here is the function that does not seem to be working
but this one does, and i have tested out the above sql query so i know it's not that. So than it must be how i define the accesorPHP Code:public function getHenCount(){
$db = new dboptions();
$record = $db->rawSelect("SELECT count(*) FROM `poultryinfo` AS total_hens WHERE `sex` = 'hen'");
return $record->fetchAll(PDO::FETCH_OBJ);
}
and here is how i do thatPHP Code:public function selectAllHens(){
$db = new dboptions();
$record = $db->rawSelect("SELECT * FROM poultryinfo WHERE `sex` = 'hen'");
return $record->fetchAll(PDO::FETCH_OBJ);
}
PHP Code:$henCount = $eggs->getHenCount(); // Get total number of hens
$records = $eggs->selectAllHens();
include_once('views/eggs_multiAdd.php');
works fine and the information is displayed in the view file just fine, but when i callPHP Code:$records = $eggs->selectAllHens()
in the view file i get Trying to get property of non-object in eggs_multiAdd.php on line 33 and that is justPHP Code:$henCount->total_hens
so i am not sure what's going on? Any insight?PHP Code:<?php echo $henCount->total_hens;?>
Thanks in advance!
-Colin



Reply With Quote




Bookmarks