Solved

PHP syntax error: unexpected end of file

Posted on 2014-11-26
8
191 Views
Last Modified: 2015-04-16
I modified a module on one of my OpenCart (v1.5.5.1) sites and it works fine, I copied those changes to another site and in one template file I have the following code line:
<?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE) { ?>

Open in new window

Which generates a "syntax error: unexpected end of file on line 162" which is the end of the template file
<?php } ?>

Open in new window

.
I don't understand why I have the error, I'd appreciate any help.
0
Comment
Question by:stoneycurtis
  • 4
  • 3
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40466594
You have a { starting a block, with no matching } ending it.
0
 

Author Comment

by:stoneycurtis
ID: 40466751
Hello ozo,
Adding the closing bracket:
<?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE) { }  ?>

Open in new window

Breaks the page.
Deleting the opening bracket:
<?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE)  ?>

Open in new window

Breaks the page.
How would I add the closing bracket?
0
 
LVL 84

Expert Comment

by:ozo
ID: 40466763
In what way does the page break?
What if you remove the entire line?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:stoneycurtis
ID: 40466794
Ozo,
By page break I mean the page returns a blank white screen.
Here is the entire code snippet:
<?php $i = 0; ?>
    <?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE) { ?>    
                <tr>
                    <td class="simplecheckout-customer-left">                       
                    </td>                    
<td class="simplecheckout-customer-right">  
                      <label><input type="radio" name="register" id="myRadio" value="1" <?php echo $register == 1 ? 'checked="checked"' : ''; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>
                      <p><?php echo $text_register_account; ?></p>
                     <label><input type="radio" name="register" id="myRadio2" value="0"  <?php echo $register == 0 ? 'checked="checked"' : ''; ?>reload="customer_not_register" /><b><?php echo $text_no ?>&nbsp;<?php echo $text_guest; ?></b></label>
                    
                  </td> 
          </tr> 
               <?php $user_choice = true; ?>
            <?php $i++ ?>           
                   

Open in new window

The code determines if a user is already logged in to his account.
What if I placed
<?php ?>

Open in new window

after
<?php $i++ ?>

Open in new window

0
 
LVL 84

Expert Comment

by:ozo
ID: 40466820
If the entire code is
<?php $i = 0; ?>
    <?php if ($i == 0 && !$customer_logged && $simple_customer_action_register == Simple::REGISTER_USER_CHOICE) { ?>    
                <tr>
                    <td class="simplecheckout-customer-left">                       
                    </td>                    
<td class="simplecheckout-customer-right">  
                      <label><input type="radio" name="register" id="myRadio" value="1" <?php echo $register == 1 ? 'checked="checked"' : ''; ?>reload="customer_register" /><b><?php echo $text_yes ?></b>&nbsp;<b><?php echo $text_register; ?></b>&nbsp;</label></br>
                      <p><?php echo $text_register_account; ?></p>
                     <label><input type="radio" name="register" id="myRadio2" value="0"  <?php echo $register == 0 ? 'checked="checked"' : ''; ?>reload="customer_not_register" /><b><?php echo $text_no ?>&nbsp;<?php echo $text_guest; ?></b></label>
                    
                  </td> 
          </tr> 
               <?php $user_choice = true; ?>
            <?php $i++ ?>           
<?php } ?>

Open in new window

Then I get no syntax error, just a "Class 'Simple' not found" error
0
 

Author Comment

by:stoneycurtis
ID: 40466851
The code is part of a larger file, I've attached it.
0
 
LVL 1

Accepted Solution

by:
Rani Sharda earned 500 total points
ID: 40468353
What I can see is missing semicolon (;) after the statement -
<?php $i++ ?>

It should be -
<?php $i++; ?>
0
 
LVL 84

Expert Comment

by:ozo
ID: 40469827
I don't see an attachment
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

773 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