Page 1 of 1

Paginator class index error

Posted: Sat Mar 15, 2014 2:46 pm
by fredep57
OK, others have had issues with paginator.class.php and I am having a different error.

So, the code area is from line 100 to 127 (the end of the class).

I am including those.

But first the errors I am getting are :
Notice: Undefined index: ipp in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 106
Notice: Undefined variable: option in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 119
Notice: Use of undefined constant ipp - assumed 'ipp' in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 111
Code from line 100 to 12y

Code: Select all

$this->return .= ($i == $this->current_page) ? "<a class=\"current\" href=\"#\">$i</a> ":"<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=$i&ipp=$this->items_per_page$this->querystring\">$i</a> ";
			}
			$this->return .= "<a class=\"paginate\" href=\"$_SERVER[PHP_SELF]?page=1&ipp=All$this->querystring\">All</a> \n";
		}
		$this->low = ($this->current_page <= 0) ? 0:($this->current_page-1) * $this->items_per_page;
		if($this->current_page <= 0) $this->items_per_page = 0;
		$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
	}
	function display_items_per_page()
	{
		$items = '';
		if(!isset($_GET[ipp])) $this->items_per_page = $this->default_ipp;
		foreach($this->ipp_array as $ipp_opt) $items .= ($ipp_opt == $this->items_per_page) ? "<option selected value=\"$ipp_opt\">$ipp_opt</option>\n":"<option value=\"$ipp_opt\">$ipp_opt</option>\n";
		return "<span class=\"paginate\">Items per page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page=1&ipp='+this[this.selectedIndex].value+'$this->querystring';return false\">$items</select>\n";
	}
	function display_jump_menu()
	{
		for($i=1;$i<=$this->num_pages;$i++)
		{
			$option .= ($i==$this->current_page) ? "<option value=\"$i\" selected>$i</option>\n":"<option value=\"$i\">$i</option>\n";
		}
		return "<span class=\"paginate\">Page:</span><select class=\"paginate\" onchange=\"window.location='$_SERVER[PHP_SELF]?page='+this[this.selectedIndex].value+'&ipp=$this->items_per_page$this->querystring';return false\">$option</select>\n";
	}
	function display_pages()
	{
		return $this->return;
	}
}

Re: Paginator class index error

Posted: Sat Mar 15, 2014 3:55 pm
by Celauran
Notice: Undefined index: ipp in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 106
Trying to use $_GET['ipp'] without first checking if it exists.

Replace this

Code: Select all

$this->limit = ($_GET['ipp'] == 'All') ? "":" LIMIT $this->low,$this->items_per_page";
With this

Code: Select all

$this->limit = (isset($_GET['ipp']) && $_GET['ipp'] == 'All') ? "" : " LIMIT $this->low,$this->items_per_page";
Notice: Undefined variable: option in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 119
Pretty self-explanatory. Define the variable inside the function, before the loop.
Notice: Use of undefined constant ipp - assumed 'ipp' in C:\wamp\www\SACCC567\admin\t3st\paginator.class.php on line 111
Array key is a string and needs to be in quotes.

Code: Select all

if (!isset($_GET['ipp'])) { $this->items_per_page = $this->default_ipp; }

Re: Paginator class index error

Posted: Sat Mar 15, 2014 8:54 pm
by fredep57
THank you!!! This fixed it.