following along with phpacademy's OOP based approach to a register/login system and I keep running into this error:
Fatal error: Call to a member function count() on a non-object in /Applications/MAMP_2014-09-25_13-13-59/htdocs/index.php on line 8
the block it's talking about is:
$user = DB::getInstance()->get('users', array('username', '=', 'henry'));
if(!$user->count()) {
echo 'no user'; }
else {
foreach($user->results() as $user)
{
echo $user->$username, '<br>';
}
}
where DB has a valid constructor, getInstance() creates a DB object if one has not been assigned, and get(), results() and count() are public function of this class.
I've googled the shit out of it and all the results so far have been flawed syntax with assigning parameters to the PDO involved in the constructor but I'm positive that's not it- it worked with queries before implementing count(). PHP WHY WON'T YOU ACCEPT $user AS AN OBJECT?