Avatar of stoneycurtis
stoneycurtis
 asked on

PHP syntax error: unexpected end of file

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.
ProgrammingSoftwareScripting Languages

Avatar of undefined
Last Comment
ozo

8/22/2022 - Mon
ozo

You have a { starting a block, with no matching } ending it.
stoneycurtis

ASKER
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?
ozo

In what way does the page break?
What if you remove the entire line?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
stoneycurtis

ASKER
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

ozo

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
stoneycurtis

ASKER
The code is part of a larger file, I've attached it.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Rani Sharda

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ozo

I don't see an attachment