Call to a member function count on a non object PO

I made the rookie mistake of starting my project in windows and migrating it to unbuntu. This move was forced upon me and resulted in a lot of unintended consequences. It generated a lot of errors one being fatal.

I know that the object is not null by simply doing a var_dump.Inside the var_dump the method is there. So my question: Why would this work flawlessly in a windows environment and not in the linux environment. I went through the code and fixed all my capitalization issues I think.

The code that generates the error is:
[php]
public function find($user = null) {
if ($user) {
$field = (is_numeric($user)) ? ‘id’ : ‘username’;

        $data = $this->_db->get('user', array($field, '=', $user));
         var_dump($data);
        if ($data->count()) {
            $this->_data = $data->first();
            return true;
        }
    }

var_dump($data);
object(DB)#3 (6) { ["_pdo":“DB”:private]=> object(PDO)#4 (0) { } ["_query":“DB”:private]=> object(PDOStatement)#5 (1) { [“queryString”]=> string(31) “SELECT * FROM user WHERE id = ?” } ["_error":“DB”:private]=> bool(false) ["_result":“DB”:private]=> array(1) { [0]=> object(stdClass)#6 (8) { [“id”]=> string(2) “39” [“username”]=> string(8) “test1234” [“password”]=> string(64) “d1dcebd95402062c466eeb1e2b5e6c3b217a0fe160bc3baac86bafc9613494e9” [“salt”]=> string(32) “.JMs.ˆ~ìdÿ)7Ð §FKS¨Ê×$'å¹Yˆc¥” [“name”]=> string(0) “” [“joined”]=> string(10) “2014-11-20” [“disabled”]=> string(1) “0” [“email”]=> string(18) "[email protected]" } } ["_count":“DB”:private]=> int(1) [“error”]=> bool(false) }

    return false;
}

[/php]

Well, that kind of work out OK for me in being duplicate post ;D, for I did some more research on this. An it is definitely a problem with the code, It has something to do with backwards compatibility of the class structure, what the solution is I don’t know? It’s a PHP version problem that I am pretty sure of.

I agree with you on your conclusion, but this leaves with another problem how do I get the PHP version to match my version on unbuntu?

First, verify that it is a versioning problem. I work on a windows workstation and have a Linux VM and server and don’t tend to have issues if you know the constraints of doing so.

Create a new page with

[php]<?php phpinfo(); ?>[/php]

On both systems. Now compare them to see the differences.

Then report back.

Sponsor our Newsletter | Privacy Policy | Terms of Service