Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post

    pagination error on online server

    On my local server it works fine. But when I upload this file shows error:
    Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in ...\searchLinkFiles\Paginated.php on line 11
    PHP Code:
    <?
    /**
     * The intention of the Paginated class is to manage the iteration of records
     * based on a specified page number usually addressed by a get parameter in the query string
     * and to use a layout interface to produce number pages based on the amount of elements
     */
    require_once "PageLayout.php";

    class 
    Paginated {

        private 
    $rs;                              //result set .....line 11
        
    private $pageSize;                      //number of records to display
        
    private $pageNumber;                    //the page to be displayed
        
    private $rowNumber;                     //the current row of data which must be less than the pageSize in keeping with the specified size
        
    private $offSet;
        private 
    $layout;

        function 
    __construct($obj$displayRows 10$pageNum 1) {
            
    $this->setRs($obj);
            
    $this->setPageSize($displayRows);
            
    $this->assignPageNumber($pageNum);
            
    $this->setRowNumber(0);
            
    $this->setOffSet(($this->getPageNumber() - 1) * ($this->getPageSize()));
        }

        
    //implement getters and setters
        
    public function setOffSet($offSet) {
            
    $this->offSet $offSet;
        }

        public function 
    getOffSet() {
            return 
    $this->offSet;
        }


        public function 
    getRs() {
            return 
    $this->rs;
        }

        public function 
    setRs($obj) {
            
    $this->rs $obj;
        }

        public function 
    getPageSize() {
            return 
    $this->pageSize;
        }

        public function 
    setPageSize($pages) {
            
    $this->pageSize $pages;
        }

        
    //accessor and mutator for page numbers
        
    public function getPageNumber() {
            return 
    $this->pageNumber;
        }

        public function 
    setPageNumber($number) {
            
    $this->pageNumber $number;
        }

        
    //fetches the row number
        
    public function getRowNumber() {
            return 
    $this->rowNumber;
        }

        public function 
    setRowNumber($number) {
            
    $this->rowNumber $number;
        }

        public function 
    fetchNumberPages() {
            if (!
    $this->getRs()) {
                return 
    false;
            }
            
            
    $pages ceil(count($this->getRs()) / (float)$this->getPageSize());
            return 
    $pages;
        }

        
    //sets the current page being viewed to the value of the parameter
        
    public function assignPageNumber($page) {
            if((
    $page <= 0) || ($page $this->fetchNumberPages()) || ($page == "")) {
                
    $this->setPageNumber(1);
            }
            else {
                
    $this->setPageNumber($page);
            }
            
    //upon assigning the current page, move the cursor in the result set to (page number minus one) multiply by the page size
            //example  (2 - 1) * 10
        
    }

        public function 
    fetchPagedRow() {
            if((!
    $this->getRs()) || ($this->getRowNumber() >= $this->getPageSize())) {
                return 
    false;
            }

            
    $this->setRowNumber($this->getRowNumber() + 1);
            
    $index $this->getOffSet();
            
    $this->setOffSet($this->getOffSet() + 1);
            return 
    $this->rs[$index];
        }

        public function 
    isFirstPage() {
            return (
    $this->getPageNumber() <= 1);
        }

        public function 
    isLastPage() {
            return (
    $this->getPageNumber() >= $this->fetchNumberPages());
        }

        
    /**
         * <description>
         * @return PageLayout <description>
         */
        
    public function getLayout() {
            return 
    $this->layout;
        }

        
    /**
         * <description>
         * @param PageLayout <description>
         */
        
    public function setLayout(PageLayout $layout) {
            
    $this->layout $layout;
        }

        
    //returns a string with the base navigation for the page
        //if queryVars are to be added then the first parameter should be preceeded by a ampersand


        
    public function fetchPagedNavigation($queryVars "") {
        
    //public function fetchPagedNavigation($queryVars) {
            
    return $this->getLayout()->fetchPagedLinks($this$queryVars);
        }
    //end writeNavigation
    }//end Paginated
    //die( "Include die" );
    ?>
    Compare bible texts (and other tools):
    TheWheelofGod

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Are you running it on php5?

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    How would I know?
    Compare bible texts (and other tools):
    TheWheelofGod

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Run a phpinfo();. The code you have is written for php5, make sure you are running php5 with your hosting.

    good luck;

  • #5
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Brandoe85 View Post
    Run a phpinfo();. The code you have is written for php5, make sure you are running php5 with your hosting.

    good luck;
    PHP Version 4.3.11.
    I guess I'm in trouble. I was rejoicing that I finally had the pagination all figured out. Sigh...
    Compare bible texts (and other tools):
    TheWheelofGod

  • #6
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    The first step is to have your host upgrade you to php5. There really isn't any reason they shouldn't already be on it.

    If all fails you can modify your code to be compatible with php4. From what your code is doing - it's not that many changes.

  • #7
    Regular Coder
    Join Date
    Mar 2005
    Posts
    735
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Brandoe85 View Post
    The first step is to have your host upgrade you to php5. There really isn't any reason they shouldn't already be on it.

    If all fails you can modify your code to be compatible with php4. From what your code is doing - it's not that many changes.
    I'm no expert in pagination. It took me weeks to work on a sample code given. And NOW I realize that it doesn't work online.
    Compare bible texts (and other tools):
    TheWheelofGod


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •