Page 1 of 1

Parse error with Prev/Next link

Posted: Thu Apr 08, 2004 10:48 am
by ~fleece~
I'm trying to make prev/next links for my blog pages and I have this code:

Code: Select all

if ($page_no != 1) {
	      $prev = $page_no - 1;
	      echo <<<END
                <a href="page.php?page_no=$prev">Previous</a>
END;
	 }
  if ($page_no != $pages) {
	      $next = $page_no + 1;
	      echo <<<END
                <a href="page.php?page_no=$next">Next</a>
END;
     }
But I always get a parse error at this line:

Code: Select all

<a href="page.php?page_no=$prev">Previous</a>
What am I doing wrong? :?

Posted: Thu Apr 08, 2004 10:54 am
by twigletmac
What does the parse error say?

Mac

Posted: Thu Apr 08, 2004 11:26 am
by ~fleece~
twigletmac wrote:What does the parse error say?

Mac
It just says :

Parse error: parse error in /home/httpd/virtual/domain.com/dir/page.php on line 47

Line 47 is the line which has the link. :(

Posted: Thu Apr 08, 2004 12:49 pm
by pickle
I have no clue what's wrong. I'd check your heredocs though for spaces before and after the closing heredoc.

Posted: Thu Apr 08, 2004 1:10 pm
by TheBentinel.com
Does it work if you don't use the heredoc at all?

Like:

Code: Select all

if ($page_no != 1) { 
         $prev = $page_no - 1; 
         echo '<a href="page.php?page_no=' . $prev . '">Previous</a>' ;
    }
If that works, then it's probably something funky with the heredoc, like pickel suggested. Maybe you can avoid using it altogether.