lalaila Posted July 21, 2012 Share Posted July 21, 2012 Hi! Neel help fixing Strict Standards: Non-static method users::count() should not be called statically, assuming $this from incompatible context in /home/gint/public_html/skelbimai/classes/groups.php on [b][color=red]line 131[/color][/b] Strict Standards: Non-static method users::count() should not be called statically, assuming $this from incompatible context in /home/gint/public_html/skelbimai/classes/groups.php on [b][color=red]line 131[/color][/b] Strict Standards: Non-static method users::count() should not be called statically, assuming $this from incompatible context in /home/gint/public_html/skelbimai/classes/groups.php on [b][color=red]line 131[/color][/b] <?php /*********************/ /* */ /* Version : 5.1.0 */ /* Author : RM */ /* Comment : 071223 */ /* */ /*********************/ class groups { public function groups( $id = 0 ) { } public function getid( ) { return $this->id; } public function getname( $id = "" ) { global $db; global $crt_lang; if ( !$id ) { $id = $this->id; } if ( $id == 1000 ) { global $lng; return clean( $lng['packages']['not_logged_in'] ); } $uname = $db->fetchRow( "select `name` from ".TABLE_USER_GROUPS."_lang where id={$id} and `lang_id`='{$crt_lang}'" ); return $uname; } public function getpackagepending( $id = "" ) { global $db; if ( !$id ) { $id = $this->id; } $ar = $db->fetchRow( "select `package_pending` from ".TABLE_USER_GROUPS." where id=\"".$id."\"" ); return $ar; } public function getlistingpending( $id = "" ) { global $db; if ( !$id ) { global $settings; return $settings['nologin_pending_listing']; } $ar = $db->fetchRow( "select `listing_pending` from ".TABLE_USER_GROUPS." where id=\"".$id."\"" ); return $ar; } public function getactivateaccount( $id = "" ) { global $db; if ( !$id ) { $id = $this->id; } $act = $db->fetchRow( "select activate_account from ".TABLE_USER_GROUPS." where id=\"".$id."\"" ); return $act; } public function getadminverification( $id = "" ) { global $db; if ( !$id ) { $id = $this->id; } $act = $db->fetchRow( "select admin_verification from ".TABLE_USER_GROUPS." where id=\"".$id."\"" ); return $act; } public function getstore( $id = "" ) { global $db; if ( !$id ) { $id = $this->id; } $ar = $db->fetchRow( "select `store` from ".TABLE_USER_GROUPS." where id=\"".$id."\"" ); return $ar; } public function getgroup( $id = "" ) { global $db; global $crt_lang; if ( !$id ) { $id = $this->id; } $result = $db->fetchAssoc( "select * from ".TABLE_USER_GROUPS." LEFT JOIN ".TABLE_USER_GROUPS."_lang on ".TABLE_USER_GROUPS.".`id` = ".TABLE_USER_GROUPS."_lang.`id` where ".TABLE_USER_GROUPS.".id='{$id}' and `lang_id` = '{$crt_lang}'" ); return $result; } public function getnoactive( ) { global $db; $no = $db->fetchRow( "select count(*) from ".TABLE_USER_GROUPS." where active=1" ); return $no; } public function nodefactivegroup( ) { global $db; $group = $db->fetchRow( "select id from ".TABLE_USER_GROUPS." where active=1" ); return $group; } public function getall( ) { global $db; global $crt_lang; $array = $db->fetchAssocList( "select ".TABLE_USER_GROUPS.".*, ".TABLE_USER_GROUPS."_lang.* from ".TABLE_USER_GROUPS." LEFT JOIN ".TABLE_USER_GROUPS."_lang on ".TABLE_USER_GROUPS.".`id` = ".TABLE_USER_GROUPS."_lang.`id` where `lang_id` = '{$crt_lang}' order by `order_no`" ); $i = 0; $array_groups = array( ); foreach ( $array as $result ) { $array_groups[$i] = $result; [color=red][b]line 131: [/b][/color] [color=red]$array_groups[$i]['users'] = users::count( $result['id'] );[/color] $array_groups[$i]['last'] = 0; if ( $i % 2 ) { $array_groups[$i]['style'] = "_odd"; } else { $array_groups[$i]['style'] = "_even"; } ++$i; } if ( $i ) { $array_groups[$i - 1]['last'] = 1; } return $array_groups; } public function getshortgroups( ) { global $db; global $crt_lang; $array = $db->fetchAssocList( "select ".TABLE_USER_GROUPS.".*, ".TABLE_USER_GROUPS."_lang.* from ".TABLE_USER_GROUPS." LEFT JOIN ".TABLE_USER_GROUPS."_lang on ".TABLE_USER_GROUPS.".`id` = ".TABLE_USER_GROUPS."_lang.`id` where `lang_id` = '{$crt_lang}' order by `order_no`" ); $i = 0; foreach ( $array as $result ) { $array[$i]['name'] = clean( $result['name'] ); ++$i; } return $array; } public function getallregister( ) { global $db; global $crt_lang; $array = $db->fetchAssocList( "select * from ".TABLE_USER_GROUPS." LEFT JOIN ".TABLE_USER_GROUPS."_lang on ".TABLE_USER_GROUPS.".`id` = ".TABLE_USER_GROUPS."_lang.`id` where auto_register=1 and `active`=1 and `lang_id` = '{$crt_lang}' order by `order_no`" ); $i = 0; $array_usr = array( ); foreach ( $array as $result ) { $array_groups[$i] = $result; if ( $i % 2 ) { $array_groups[$i]['style'] = "_odd"; } else { $array_groups[$i]['style'] = "_even"; } ++$i; } return $array_groups; } public function exists( $id ) { global $db; $res = $db->query( "select * from ".TABLE_USER_GROUPS." where id='{$id}'" ); if ( $db->numRows( $res ) ) { return 1; } return 0; } public function nodefregistergroup( ) { global $db; $group = $db->fetchRow( "select id from ".TABLE_USER_GROUPS." where auto_register=1 and active=1" ); return $group; } public function nodefgroup( ) { global $db; $group = $db->fetchRow( "select id from ".TABLE_USER_GROUPS." where active=1" ); return $group; } } ?> thanks all for help! Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/ Share on other sites More sharing options...
Fadion Posted July 21, 2012 Share Posted July 21, 2012 Does the Users class have a static method count()? If not, just initialize the object and call the method with the -> operator. Post the code of the User class, just in case. Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/#findComment-1363263 Share on other sites More sharing options...
lalaila Posted July 21, 2012 Author Share Posted July 21, 2012 Does the Users class have a static method count()? If not, just initialize the object and call the method with the -> operator. Post the code of the User class, just in case. there it is! 18695_.php Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/#findComment-1363286 Share on other sites More sharing options...
Fadion Posted July 22, 2012 Share Posted July 22, 2012 My previous post should have given you the reply. As you're coding with objects, you should have the basic understanding on how they're initialized. Anyway, replace the static call to the user class with a typical object initialization: $users = new Users; $users->count(); I'm also seeing a lot of global calls ($db) that don't really make sense in class context where you're trying to separate concerns. There are better ways to manage dependencies. For your groups class: <?php class Groups { protected $db; protected $users; public function __construct (Database $database, Users $users) { $this->db = $database; $this->users = $users; } public function whatever_method () { $this->db->fetchRow("some query"); } } $groups = new Groups(new Database, new Users); $groups->whatever_method(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/#findComment-1363396 Share on other sites More sharing options...
lalaila Posted July 22, 2012 Author Share Posted July 22, 2012 Can you just fix this error? im bad i PHP thanks My previous post should have given you the reply. As you're coding with objects, you should have the basic understanding on how they're initialized. Anyway, replace the static call to the user class with a typical object initialization: $users = new Users; $users->count(); I'm also seeing a lot of global calls ($db) that don't really make sense in class context where you're trying to separate concerns. There are better ways to manage dependencies. For your groups class: <?php class Groups { protected $db; protected $users; public function __construct (Database $database, Users $users) { $this->db = $database; $this->users = $users; } public function whatever_method () { $this->db->fetchRow("some query"); } } $groups = new Groups(new Database, new Users); $groups->whatever_method(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/#findComment-1363435 Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2012 Share Posted July 22, 2012 Can you just fix this error? im bad i PHP thanks This site is here to help you learn, not do your work for you. Quote Link to comment https://forums.phpfreaks.com/topic/266033-idk-how-to-fix-that-errors-help/#findComment-1363469 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.