PHP Classes

Fixed the errors I found in the class

Recommend this page to a friend!

      Simple Paginator  >  All threads  >  Fixed the errors I found in the class  >  (Un) Subscribe thread alerts  
Subject:Fixed the errors I found in the class
Summary:I fixed the errors that I was referring to in my previous post
Messages:1
Author:William Dodson
Date:2006-11-06 18:57:34
 

  1. Fixed the errors I found in the class   Reply   Report abuse  
Picture of William Dodson William Dodson - 2006-11-06 18:57:34
I fixed the errors that I was referring to in my previous post. Here is what I found and how to fix it:

1. For some odd reason, $results_per_page was being reset to an empty string after the functionality that determines the offset and limit vars ($offset and $limit, respectively.) The quick fix was to copy the value of $results_per_page into another var called $num_per_page. You could also define it as a constant or set it as a global (e.g. define('RESULTS_PER_PAGE', 10) or global $results_per_page = 10.) Although a constant seems to perform better, IMHO, this is a style matter. Either should work.

2. The line that echoes the pagination links to the page had a syntax error. What was:
echo $paginator->$pagination;
Should read:
echo $paginator->pagination; (no $ sign on the class property.)

Hopefully this will help you out and also make it clear that I wasn't trying to come across in the wrong manner with regards to my previous post on Unit Testing. Although a good unit test would have caught this error. Enjoy! :)