Jump to content

Idk how to fix that errors HELP! :)


lalaila

Recommended Posts

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!

Link to comment
Share on other sites

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();
?>

Link to comment
Share on other sites

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();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.