Error of Non-static method DB_Connection

i am developing online computer shopping site. i have problem in product.php class
i am getting error of
Strict standards: Non-static method DB_Connection::obj_db() should not be called statically in D:\wamp\www\project\ali\models\product.php on line 85
Product::get_products( )

Strict standards: Non-static method DB_Connection::obj_db() should not be called statically in D:\wamp\www\project\ali\models\product.php on line 150
Product::pagination( )

here is my attach code, kindly help me to fix the error !

product.php (5.5 KB)

`
thanks

1 Like

solution is simple, don’t call a non-static method statically.

@Dormilich the solution is indeed simple.

@aliqayyum Do you want to call it static or not ?

i want to call as static function

then you have to define the method as static.

You would have to do this :

<?php 
// Your class

public static obj_db() { // Note : static << 
}

in start of product.php ?

in the class definition.

works fine, i have removed abstract from db and used like this
$obj_db = (new DB_Connection)->obj_db();
thanks

Well then it is fixed.

I doubt it would have worked the other way round (declaring it static).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.