Error "Too few arguments to function"

GermanMech picture GermanMech · Nov 9, 2017 · Viewed 24.1k times · Source

I got an error in the following code piece: Too few arguments to function showtbl::GetTabellen_ns(), 0 passed in abcde/folder/php.php on line 153 and exactly 2 expected

Don't know why I get this. I'm quite new to PHP Prado and in all programming so maybe a stupid mistake.

protected function GetTabellen_ns($offset, $limit) 
{
    $criteria=new TActiveRecordCriteria;
    $criteria->Condition = 'name = $name';
    $criteria->OrdersBy['name'] = 'asc';
    $criteria->Limit = 15;
    $criteria->Offset = 20;

    return prdtblRecord::finder()->findAll($criteria);           
}

protected function populateData_ns($offset, $limit) 
{
    $offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
    $limit=$this->Repeater->PageSize;
    if($offset+$limit>$this->Repeater->VirtualItemCount) {
        $limit=$this->Repeater->VirtualItemCount-$offset;
    }
    $this->Repeater->DataSource=$this->GetTabellen_ns($offset,$limit);
    $this->Repeater->dataBind();
}

Thx for help hope someone can help me.

edit: If someone can tell me how $offset and $limit get set would help me alot too.

Answer

Feralheart picture Feralheart · Nov 9, 2017

You call the function like this: $this->GetTabellen_ns()

But function needs two arguments (offset and limit).

If you want to set these argument as optional argument, you can give them a default value like this:

protected function GetTabellen_ns($offset = 0, $limit = 0){
 .
 .
 .
}