Unexpected "=" - why? what to do?

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

Post Reply
abrogard
Forum Newbie
Posts: 11
Joined: Sun Apr 04, 2004 6:02 am

Unexpected "=" - why? what to do?

Post by abrogard »

I get this error message:

Parse error: parse error, unexpected '=' in c:\Inetpub\wwwroot\xyford\manual\mybook.php on line 46

And here's line 46. The "=" causing the trouble is, I think, the "chapter=" one.

if ($prevPage > $chapters[$chapter][0]) $out .= "<a href="/mybook.php?chapter={$chapter}&page={$prevPage}">Prev</a>";

I can't see what to do about it.

Can anyone help?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Unexpected "=" - why? what to do?

Post by McInfo »

abrogard wrote:

Code: Select all

if ($prevPage > $chapters[$chapter][0]) $out .= "<a href="/mybook.php?chapter={$chapter}&page={$prevPage}">Prev</a>";
Quotes in strings must be escaped. Otherwise, they prematurely terminate the string.

Code: Select all

if ($prevPage > $chapters[$chapter][0]) $out .= "<a href=\"/mybook.php?chapter={$chapter}&page={$prevPage}\">Prev</a>";
Post Reply