hi im following a tutorial for a system running on PDO and i have encountered a error can anyone check this out
Fatal error: Call to a member function count() on a non-object in /home/matureco/public_html/classes/User.php on line 21
user.php
public function find($user = null) {
if($user) {
$field = (is_numeric($user)) ? 'id' : 'username';
$data = $this->_db->get('users', array($field, '=', $user));
if($data->count()) { // this is the one getting the error from
$this->_data = $data->first();
return true;
}
}
return false;
}
public function login($username = null, $password = null) {
$user = $this->find($username);
print_r($this->_data);
return false;
}
login.php
<?php
require_once 'core/init.php';
if(Input::exists()) {
if(Token::check(Input::get('token'))) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array('required' => true),
'password' => array('required'=> true),
));
if($validation->passed()) {
$user = new User();
$login = $user->login(Input::get('username'), Input::get('password'));
if($login) {
echo 'Success';
} else {
echo '<p>Sorry, logging in failed.</p>';
}
} else {
foreach($validation->errors() as $error) {
echo $error, '<br>';
}
}
}
}
?>
any help would be much appreciated ty x