Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Syntax Error

Posted on 2012-08-16
Medium Priority
Last Modified: 2012-08-20
Have a syntax error on 3rd line from the bottom I added this line of code which resulted in the syntax error at the bottom of the page  <?php
      if ($WA_Store_Cart->TotalColumn("TotalPrice") >= 49.99 && !($WA_Store_Cart->InCart("1418") == true))  {
  </div> I would like to have to specials running one that pulls when there is $99.99 in the cart and the other when there is $49.99 in the cart.  Thank you in advance for your assistance.  Greatly appreciate jason1178 telling me to repost
Question by:glozinski
  • 4
  • 3
LVL 13

Expert Comment

ID: 38303175
Because you opened a brace { but never close it before the script ends.

Your question isn't that informative.

Give us the complete script that isn't working, along with the exact URI (including get arguments) needed to get the expected result, and also tell us the exact error message, line # included.

Expert Comment

ID: 38303227
If you are conditionally showing the HTML the format is '<?php if(condition) : ?>...<?php elseif(condition) : ?>...<?php else : ?>...<?php endif; ?>', where the ...'s are HTML content, I.e....

<?php if($WA_Store_Cart->TotalColumn("TotalPrice") >= 99.99 && 
	!($WA_Store_Cart->InCart("1418") == true)) : ?>
<div>99.99 Special!</div>

<?php elseif($WA_Store_Cart->TotalColumn("TotalPrice") >= 49.99 &&
	!($WA_Store_Cart->InCart("1418") == true)) : ?>
<div>49.99 Special!</div>

<?php endif; ?>

Open in new window

Is that what you meant?

Author Comment

ID: 38305844
Yes, that is what I meant.  I inserted the above code and I have an error on this line
 <?php } // End Show Region ?>
//WA eCart Show If Middle
}This is the line where it states that is now an syntax error
else     {
?><div class="contentBox ps_pod1 borderColor"><p>The cart is empty.</p></div>
//WA eCart Show If End

Thank you in advance
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 38306036
Well, Without all the code before it we can't really check to see if the curly braces match up. Can you post all of the code? You haven't mentioned what the actual error is but I imagine the problem is that the closing bracket on that line is not expected.

Author Comment

ID: 38306117
I have two Specials: one when the customer has $49.99 in the cart and then one when the customer has $99.99 in the cart (perhaps both can appear and both be available in this one)  if you were to go to this http://www.creativeplantinteriors.com/cart.php then view source "1" shows but in DW says that the error is on line 475 which is
//WA eCart Show If Middle
}this line
Hopefully this explains it better...Thank you in advance Greatly Appreciate all efforts!!!

Accepted Solution

Psyberion earned 1000 total points
ID: 38306533
Thanks, that's better. First of all I have to say you don't need to wrap every individual PHP statement or comment in their own <?php ... ?> tags. Also if you have an 'if' or 'else' with just one statement you don't need to wrap it in curly braces.

I've reformatted your file, removed the extraneous <?php ?> tags, by merging consecutive ones together and then indented the PHP that controls the output of HTML so that it's easier to see starting {'s and their matching ending }'s.

This has helped me spot one place where the braces are closed at one point but it's not the matching ending brace judging by the comments. So, try and follow the following steps in the reformatted file I've included (the line numbers won't match your file):

[1] All the PHP up to line 183 closes all braces it opens, so that's fine.
[2] Line 196 opens a section labelled '//WA eCart Show If Start'.
[3] This opening of braces is closed on line 343.
[4] Line 472 closes right against the left (with no indentation) but then there's another closing brace after it on line 478 commented as '//WA eCart Show If Middle', this one doesn't have a matching opening brace and this is the comment shown in your error. As I predicted PHP is not expecting another closing brace because there's no matching opening brace, all the previous opening braces have already been closed.
[5] Line 485, the final closing brace has the comment '//WA eCart Show If End' before it. This should be closing the brace that goes with the comment in point [2] above.

So, there's an extra closing bracket in your code, somewhere between line 196 and line 472. Now without deciphering all your code and trying to work out what it should be doing, I can't really say which closing bracket is the culprit.

However, I would suggest you try commenting out the one on line 343 and then give it a try and make sure the page is rendered correctly. If that doesn't work then you will need to work through and check the if statements, particularly between lines 196 and 472, and make sure that they only span over the HTML sections that they should be controlling.

Does that make sense?


Author Closing Comment

ID: 38314078
Thank you soooo much for your assistance.  Up and running greatly appreciate it.

Expert Comment

ID: 38314371
My pleasure, I'm glad it worked. These kind of errors where there's a missing or extra character can be an utter nightmare I know.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question