• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Xampp/website error

UchihaClan

Only you can be you
Joined
Oct 25, 2014
Messages
164
Reaction score
33
Hello !

I´m getting this error when sombody is trying to click on a guild to watch the guild (example if sombody wanna joina guild they can´t) they get this error
Fatal error: Call to a member function fetchAll() on a non-object in C:\xampp\htdocs\classes\databaselist.php on line 68

I use tfs 0.4 (tibia 8.6)


This is my line 68
Code:
     public function getResult($id)[/B]

Forgot this is my databaselist.php
Code:
<?php
if(!defined('INITIALIZED'))
    exit;

class DatabaseList extends DatabaseHandler implements Iterator, Countable
{
    public $data;
    public $iterator = 0;
    public $class;
    public $table;
    public $tables = array();
    public $fields = array();
    public $extraFields = array();
    public $filter;
    public $orders = array();
    public $limit;
    public $offset = 0;

    public function __construct($class = null)
    {
        if($class !== null)
            $this->setClass($class);
    }

    public function load()
    {
        $fieldsArray = array();

        if(count($this->fields) > 0)
            foreach($this->fields as $fieldName)
                    $fieldsArray[$fieldName] = $this->getDatabaseHandler()->tableName($this->table) . '.' . $this->getDatabaseHandler()->fieldName($fieldName);

        if(count($this->extraFields) > 0)
            foreach($this->extraFields as $field)
                if(!$field->hasAlias())
                    $fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName());
                else
                    $fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName()) . ' AS ' . $this->getDatabaseHandler()->fieldName($field->getAlias());

        $tables = array();
        foreach($this->tables as $table)
            $tables[] = $this->getDatabaseHandler()->tableName($table);

        $filter = '';
        if($this->filter !== null)
            $filter = ' WHERE ' .$this->filter->__toString();

        $order = '';
        $orders = array();
        if(count($this->orders) > 0)
        {
            foreach($this->orders as $_tmp_order)
                $orders[] = $_tmp_order->__toString();
            if(count($orders) > 0)
                $order = ' ORDER BY ' . implode(', ', $orders);
        }

        $limit = '';
        if($this->limit !== null)
            $limit = ' LIMIT ' . (int) $this->limit;

        $offset = '';
        if($this->offset > 0)
            $offset = ' OFFSET ' . (int) $this->offset;

        $query = 'SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . implode(', ', $tables) . $filter . $order . $limit . $offset;

        $this->data = $this->getDatabaseHandler()->query($query)->fetchAll();
    }

    public function getResult($id)
    {
        if(!isset($this->data))
            $this->load();
        if(isset($this->data[$id]))
        {
            if(!is_object($this->data[$id]))
            {
                $_tmp = new $this->class();
                $_tmp->loadData($this->data[$id]);
                return $_tmp;
            }
            else
                return $this->data[$id];
        }
        else
            return false;
    }

    public function addExtraField($field)
    {
        $this->extraFields[] = $field;
        $this->addTables($field->getTable());
    }

    public function addOrder($order)
    {
        $this->orders[] = $order;
    }

    public function setClass($class)
    {
        $this->class = $class;
        $instance = new $this->class();
        $this->fields = $instance::$fields;
        if(isset($instance::$extraFields))
            foreach($instance::$extraFields as $extraField)
            {
                if(!isset($extraField[2]))
                    $this->extraFields[] = new SQL_Field($extraField[0], $extraField[1]);
                else
                    $this->extraFields[] = new SQL_Field($extraField[0], $extraField[1], $extraField[2]);
                $this->tables[$extraField[1]] = $extraField[1];
            }
        $this->table = $instance::$table;
        $this->tables[$instance::$table] = $instance::$table;
    }

    public function setFilter($filter)
    {
        $this->addTables($filter->getTables());
        $this->filter = $filter;
    }

    public function setLimit($limit)
    {
        $this->limit = $limit;
    }

    public function setOffset($offset)
    {
        $this->offset = $offset;
    }

    public function addTables($tables)
    {
        if(is_array($tables))
        {
            foreach($tables as $table)
                if($table != '' && !in_array($table, $this->tables))
                    $this->tables[$table] = $table;
        }
        elseif($tables != '' && !in_array($tables, $this->tables))
            $this->tables[$tables] = $tables;
    }

    public function current()
    {
        return $this->getResult($this->iterator);
    }

    public function rewind()
    {
        if(!isset($this->data))
            $this->load();
        $this->iterator = 0;
    }

    public function next()
    {
        ++$this->iterator;
    }

    public function key()
    {
        return $this->iterator;
    }

    public function valid()
    {
        return isset($this->data[$this->iterator]);
    }

    public function count()
    {
        if(!isset($this->data))
            $this->load();
        return count($this->data);
    }
}
 
Last edited by a moderator:
Okey...Now I get a massive of errors
Code:
Query:SELECT `id`, `world_id`, `name`, `ownerid`, `creationdata`, `motd`, `description`, `create_ip`, `guild_logo` FROM `guilds` WHERE `id` = '3'
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `create_ip`, `create_date`, `comment`, `hide_char` FROM `players` WHERE `id` = '73'
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `guild_ranks`.`id`, `guild_ranks`.`guild_id`, `guild_ranks`.`name`, `guild_ranks`.`level` FROM `guild_ranks` WHERE `guild_id` = '3' ORDER BY `level` DESC
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `players`.`id`, `players`.`name`, `players`.`world_id`, `players`.`group_id`, `players`.`account_id`, `players`.`level`, `players`.`vocation`, `players`.`health`, `players`.`healthmax`, `players`.`experience`, `players`.`lookbody`, `players`.`lookfeet`, `players`.`lookhead`, `players`.`looklegs`, `players`.`looktype`, `players`.`lookaddons`, `players`.`maglevel`, `players`.`mana`, `players`.`manamax`, `players`.`manaspent`, `players`.`soul`, `players`.`town_id`, `players`.`posx`, `players`.`posy`, `players`.`posz`, `players`.`conditions`, `players`.`cap`, `players`.`sex`, `players`.`lastlogin`, `players`.`lastip`, `players`.`save`, `players`.`skull`, `players`.`skulltime`, `players`.`rank_id`, `players`.`guildnick`, `players`.`lastlogout`, `players`.`blessings`, `players`.`balance`, `players`.`stamina`, `players`.`direction`, `players`.`loss_experience`, `players`.`loss_mana`, `players`.`loss_skills`, `players`.`loss_containers`, `players`.`loss_items`, `players`.`premend`, `players`.`online`, `players`.`marriage`, `players`.`promotion`, `players`.`deleted`, `players`.`description`, `players`.`create_ip`, `players`.`create_date`, `players`.`comment`, `players`.`hide_char` FROM `players` WHERE `rank_id` = '7' ORDER BY `name` ASC
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `players`.`id`, `players`.`name`, `players`.`world_id`, `players`.`group_id`, `players`.`account_id`, `players`.`level`, `players`.`vocation`, `players`.`health`, `players`.`healthmax`, `players`.`experience`, `players`.`lookbody`, `players`.`lookfeet`, `players`.`lookhead`, `players`.`looklegs`, `players`.`looktype`, `players`.`lookaddons`, `players`.`maglevel`, `players`.`mana`, `players`.`manamax`, `players`.`manaspent`, `players`.`soul`, `players`.`town_id`, `players`.`posx`, `players`.`posy`, `players`.`posz`, `players`.`conditions`, `players`.`cap`, `players`.`sex`, `players`.`lastlogin`, `players`.`lastip`, `players`.`save`, `players`.`skull`, `players`.`skulltime`, `players`.`rank_id`, `players`.`guildnick`, `players`.`lastlogout`, `players`.`blessings`, `players`.`balance`, `players`.`stamina`, `players`.`direction`, `players`.`loss_experience`, `players`.`loss_mana`, `players`.`loss_skills`, `players`.`loss_containers`, `players`.`loss_items`, `players`.`premend`, `players`.`online`, `players`.`marriage`, `players`.`promotion`, `players`.`deleted`, `players`.`description`, `players`.`create_ip`, `players`.`create_date`, `players`.`comment`, `players`.`hide_char` FROM `players` WHERE `rank_id` = '8' ORDER BY `name` ASC
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `players`.`id`, `players`.`name`, `players`.`world_id`, `players`.`group_id`, `players`.`account_id`, `players`.`level`, `players`.`vocation`, `players`.`health`, `players`.`healthmax`, `players`.`experience`, `players`.`lookbody`, `players`.`lookfeet`, `players`.`lookhead`, `players`.`looklegs`, `players`.`looktype`, `players`.`lookaddons`, `players`.`maglevel`, `players`.`mana`, `players`.`manamax`, `players`.`manaspent`, `players`.`soul`, `players`.`town_id`, `players`.`posx`, `players`.`posy`, `players`.`posz`, `players`.`conditions`, `players`.`cap`, `players`.`sex`, `players`.`lastlogin`, `players`.`lastip`, `players`.`save`, `players`.`skull`, `players`.`skulltime`, `players`.`rank_id`, `players`.`guildnick`, `players`.`lastlogout`, `players`.`blessings`, `players`.`balance`, `players`.`stamina`, `players`.`direction`, `players`.`loss_experience`, `players`.`loss_mana`, `players`.`loss_skills`, `players`.`loss_containers`, `players`.`loss_items`, `players`.`premend`, `players`.`online`, `players`.`marriage`, `players`.`promotion`, `players`.`deleted`, `players`.`description`, `players`.`create_ip`, `players`.`create_date`, `players`.`comment`, `players`.`hide_char` FROM `players` WHERE `rank_id` = '9' ORDER BY `name` ASC
SQLSTATE:00000
Driver code: 
Error message: 
Query:SELECT `players`.`id`, `players`.`name`, `players`.`world_id`, `players`.`group_id`, `players`.`account_id`, `players`.`level`, `players`.`vocation`, `players`.`health`, `players`.`healthmax`, `players`.`experience`, `players`.`lookbody`, `players`.`lookfeet`, `players`.`lookhead`, `players`.`looklegs`, `players`.`looktype`, `players`.`lookaddons`, `players`.`maglevel`, `players`.`mana`, `players`.`manamax`, `players`.`manaspent`, `players`.`soul`, `players`.`town_id`, `players`.`posx`, `players`.`posy`, `players`.`posz`, `players`.`conditions`, `players`.`cap`, `players`.`sex`, `players`.`lastlogin`, `players`.`lastip`, `players`.`save`, `players`.`skull`, `players`.`skulltime`, `players`.`rank_id`, `players`.`guildnick`, `players`.`lastlogout`, `players`.`blessings`, `players`.`balance`, `players`.`stamina`, `players`.`direction`, `players`.`loss_experience`, `players`.`loss_mana`, `players`.`loss_skills`, `players`.`loss_containers`, `players`.`loss_items`, `players`.`premend`, `players`.`online`, `players`.`marriage`, `players`.`promotion`, `players`.`deleted`, `players`.`description`, `players`.`create_ip`, `players`.`create_date`, `players`.`comment`, `players`.`hide_char` FROM `players`, `guild_invites` WHERE `guild_invites`.`guild_id` = '3' AND `players`.`id` = `guild_invites`.`player_id` ORDER BY `players`.`name` ASC
SQLSTATE:42S02
Driver code:1146
Error message:Table 'evo.guild_invites' doesn't exist

[B]Fatal error[/B]: Call to a member function fetchAll() on a non-object in [B]C:\xampp\htdocs\classes\databaselist.php[/B] on line [B]68[/B]

In index.php set DEBUG_DATABASE false to true to see the error.
PHP:
define('DEBUG_DATABASE', true);
^^
 
Last edited by a moderator:
Code:
CREATE TABLE `guild_invites`
(
   `player_id` INT NOT NULL DEFAULT 0,
   `guild_id` INT NOT NULL DEFAULT 0,
   UNIQUE (`player_id`, `guild_id`),
   FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
   FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE
) ENGINE = InnoDB;
http://otland.net/threads/mysql-how-to-run-a-query.177833/
 
Code:
CREATE TABLE `guild_invites`
(
   `player_id` INT NOT NULL DEFAULT 0,
   `guild_id` INT NOT NULL DEFAULT 0,
   UNIQUE (`player_id`, `guild_id`),
   FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
   FOREIGN KEY (`guild_id`) REFERENCES `guilds`(`id`) ON DELETE CASCADE
) ENGINE = InnoDB;
http://otland.net/threads/mysql-how-to-run-a-query.177833/
#1050 - Table 'guild_invites' already exists
 
Back
Top