PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
~fleece~
Forum Newbie
Posts: 12 Joined: Sun Apr 04, 2004 10:18 pm
Post
by ~fleece~ » Thu Apr 08, 2004 10:48 am
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?
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Apr 08, 2004 10:54 am
What does the parse error say?
Mac
~fleece~
Forum Newbie
Posts: 12 Joined: Sun Apr 04, 2004 10:18 pm
Post
by ~fleece~ » Thu Apr 08, 2004 11:26 am
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.
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Thu Apr 08, 2004 12:49 pm
I have no clue what's wrong. I'd check your heredocs though for spaces before and after the closing heredoc.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
TheBentinel.com
Forum Contributor
Posts: 282 Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio
Post
by TheBentinel.com » Thu Apr 08, 2004 1:10 pm
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.