Avatar of sallywizard
sallywizard
 asked on

Why am I getting a parse error: syntax error, unexpected T_IF

this is the error: Parse error: syntax error, unexpected T_IF

the If is after a switch, which I believe I closed appropriately.
  this is the offending line:        (if $prevpage >0) (line 127 in code)
  this is the next offending line:           (if $nextpagenum!=11) {

If I remove the IFs (after the switch), then the page displays fine. no errors

I usually work in VBscript and this is my simple foray into PHP.

thx,
<?php
		$designpage = $_REQUEST['np']; 
		echo  $designpage;
//	'this page is included in the design.php page to deliver the particular designs to viewers
	
?>
<?php
	if ($_REQUEST['np'] =="" ) 
		$designpage = 1;
?>
<?php
	$prevpage = $designpage-1;
	//the following is just for testing to assure the calcs are correct
	echo $prevpage; echo "&nbsp;";
	//the following is just for testing to assure the calcs are correct
	$nextpagenum = $designpage+1;
	echo $nextpagenum; echo  "<br/>";		
	
//depending on the designpage, display images and pricing
	switch ($designpage) {
		CASE 1:
?>
			<p ><img src="images/styles/styles_backup/6dozcube150.jpg" alt="Six Dozen Roses" width="480" height="360"/></p>
			<p >6 dozen Roses arranged in an 8 inch cube vase<br/><span class="pricing">$150</span></p>
			<p ><img src="images/styles/styles_backup/Much.jpg" alt="Much Love" width="480" height="360"/></p>
			<p >Much Love<br/><span class="pricing">$150,compare at $200</span></p>
			<p ><img src="images/styles/styles_backup/lotsoflove2.jpg" alt="Lots of Love" width="480" height="324"/></p>
			<p >Lots of Love<br/><span class="pricing">$150,compare at $200</span></p>
<?php
			break;
		CASE 2:
?>
			<p><img src="images/styles/styles_backup/Cool.jpg" alt="Tropical Punch" width="480" height="610" /></p>
			<p >Tropical Punch <br/><span class="pricing">$75</span></p>
			<p><img src="images/styles/styles_backup/Warm_1.jpg" alt="Tahiti" width="480" height="640" /></p>
			<p >Tahiti<br/><span class="pricing">$75</span></p>
			<p><img src="images/styles/styles_backup/blush60.jpg" alt="Blush" width="480" height="464" /></p>
			<p >Blush<br/><span class="pricing">$60</span></p>
<?php
			break;
		CASE 3:
?>
				<p><img src="images/styles/styles_backup/2doz60.jpg" alt="Two Dozen Red Roses" width="480" height="529" /></p>
				<p >Two Dozen Red Roses<span class="pricingred">$100 during Valentines week </span></p>
				<p><img src="images/styles/styles_backup/pink60.jpg" alt="In the Pink" width="480" height="401" /></p>
				<p >In the Pink<br/><span class="pricing">$60</span></p>
				<p><img src="images/styles/styles_backup/Monochromatic60.jpg" alt="Monochromatic" width="480" height="558" /></p>
				<p >Monochromatic in Cedar Box<br/><span class="pricing">$60</span></p>
<?php
			break;
		CASE 4:
?>
				<p><img src="images/styles/styles_backup/goldandgreen50.jpg" alt="Gold and Green" width="480" height="470" /></p>
				<p >Gold and Green<br/><span class="pricing">$60</span></p>
				<p><img src="images/styles/styles_backup/frosty50.jpg" alt="Frosty" width="480" height="360" /></p>
				<p >Frosty<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/SummerSun.jpg" alt="Summer Sun" width="480" height="556" /></p>
				<p >Summer Sun<br/><span class="pricing">$50</span></p>
<?php
			break;
		CASE 5:
?>
				<p><img src="images/styles/styles_backup/pastelSpring.JPG" alt="Pastel Spring" width="480" height="463" /></p>
				<p >Pastel Spring<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/seasonalSpring50.jpg" alt="Seasonal Springtime" width="480" height="640" /></p>
				<p >Seasonal Springtime<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/spicy50.jpg" alt="spicy" width="480" height="640" /></p>
				<p >Spicy<br/><span class="pricing">$50</span></p>
<?php
			break;
		CASE 6:
?>
				<p><img src="images/styles/styles_backup/Jeweltone.jpg" alt="Jeweltone" width="480" height="360" /></p>
				<p >Jeweltone<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/wintergreen50.jpg" alt="Tropical Winter Green" width="480" height="458" /></p>
				<p >Tropical Winter Green<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/DeluxeSpring.jpg" alt="Deluxe Spring" width="480" height="446" /></p>
				<p >Deluxe Spring<br/><span class="pricing">$50</span></p>
						  
<?php
			break;
		CASE 7:
?>
				<p><img src="images/styles/styles_backup/PeachesCream40.jpg" alt="Peaches and Cream" width="480" height="360" /></p>
				<p >Peaches and Cream<br/><span class="pricing">$40</span></p>
				<p><img src="images/styles/styles_backup/Periwinkle40.jpg" alt="Periwinkle" width="480" height="640" /></p>
				<p >Periwinkle<br/><span class="pricing">$40</span></p>
						  
<?php
			break;
		CASE 8:
?>
				<p><img src="images/styles/styles_backup/2091.jpg" alt="Dutch Winter" width="480" height="360" /></p>
				<p >Dutch Winter<br/><span class="pricing">$50</span></p>
				<p><img src="images/styles/styles_backup/Wild.jpg" alt="Wild Berry" width="480" height="459" /></p>
				<p >Wild Berry<br/><span class="pricing">$40</span></p>
				<p><img src="images/styles/styles_backup/Seasonal.jpg" alt="Dutch Springtime" width="480" height="457" /></p>
				<p >Dutch Springtime<br/><span class="pricing">$40</span></p>
<?php
			break;
		CASE 9:
?>
				<p><img src="images/styles/styles_backup/Warm_2.jpg" alt="Breakaway Set" width="480" height="360" /></p>
				<p >Breakaway Set<br/><span class="pricing">$40</span></p>
				<p><img src="images/styles/styles_backup/White.jpg" alt="Cool Breeze" width="480" height="360" /></p>
				<p >Cool Breeze<br/><span class="pricing">$40</span></p>
<?php
			break;
		CASE 10:
?>
				<p><img src="images/styles/styles_backup/Sympathy_3.jpg" alt="Sympathy number4" width="480" height="640" /></p>
				<p >Sympathy #4 <br/><span class="pricing">$200</span></p>
				<p><img src="images/styles/styles_backup/Sympathy_2.jpg" alt="Sympathy number3" width="480" height="529" /></p>
				<p >Sympathy #3<br/><span class="pricing">$150</span></p>
				<p><img src="images/styles/styles_backup/Sympathy_1.jpg" alt="Sympathy number2" width="480" height="640" /></p>
				<p >Sympathy #2 <br/><span class="pricing">$150</span></p>
				"<p><img src="images/styles/styles_backup/Sympathy.jpg" alt="Sympathy number1" width="480" height="647" /></p>
				"<p>Sympathy #1  <br/><span class="pricing">$100</span></p>
<?php
			break;
//end of the switch cases
}							
?>
<p >
<?php	
	//now check for and write link to previous page
	(if $prevpage >0) 
	?>
	 &raquo;<a href="designs.asp?np=<?php echo $prevpage; ?>">Previous Styles</a>
<?php 
?>
&nbsp;&nbsp;&nbsp;&nbsp;
<?php

	//now check for and write link to next page
	(if $nextpagenum!=11) {
?>
	<a href="designs.asp?np=<? echo $nextpagenum ?>" >More Styles &raquo;</a>
<?php
	 } 
?>

</p>

Open in new window

PHPScripting Languages

Avatar of undefined
Last Comment
OmniUnlimited

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dave Baldwin

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
OmniUnlimited

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
sallywizard

ASKER
Thanks.

It's sometimes the little things - misplaced ( or ; or ' that we just miss.

Just curious - Are the brackets required or are they "just" good form?
Dave Baldwin

In PHP, they are required.  php.net is your friend.  http://www.php.net/manual/en/control-structures.if.php
OmniUnlimited

Within PHP itself, the braces are not required for one line statements.

Example:

if (true)
   echo "true";
else
   echo "false";

They are required for more than one line:

if (true) {
   echo "This still is ";
   echo "true";
} else {
   echo "This still is ";
   echo "false";
}

In this case, where you leave PHP and encode some HTML, the braces are required in order for you to obtain an expected result:

<?php
if (true) { ?>
    <div>This is true</div>
<?php } else { ?>
    <div>This is false</div>
<?php }
?>
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
sallywizard

ASKER
thanks. That's very helpful.
OmniUnlimited

No problem.  Thank you for the points!