Solved

PHP syntax error: unexpected end of file

Posted on 2014-11-26
8
174 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A list of useful business intelligence software.
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…
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now