Search code examples
phpparse-error

PHP Parse error in localhost


The below code is running a portion of my code file and this file is running perfect in my server whereas when I am trying to run this code in my own system using WAMP server I am getting Parse error: syntax error, unexpected end of file whereas I copied the code in NetBeans IDE and lots of PHP syntax checking online tools but no error was detected by them. However unless I remove the below code I am unable to run the code file. I have two questions

  1. Is it possible to disable the Parse Error in PHP settings so as it runs as the same way running in my server.

  2. Can anyone point out what's wrong in the below code.

.

<?php 
                if ($current_main == "admin")
                {
            ?>
                <li><a href="<?php echo base_url();?>admin/addsite" title="Administrator">Administrator</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "admin_addsite")
                {
            ?>
                <li><a href="<?php echo base_url();?>admin/addsite" title="Add Sites">Add Sites</a></li>
            <?
                }
            ?>


            <?php 
                if ($current_main == "reportmanager")
                {
            ?>
                <li><a href="<?php echo base_url();?>report/view" title="Report Manager">Report Manager</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "viewreport")
                {
            ?>
                <li><a href="<?php echo base_url();?>report/view" title="View Report">View Report</a></li>
            <?
                }
            ?>


            <?php 
                if ($current_main == "listsitemanager")
                {
            ?>
                <li><a href="<?php echo base_url();?>listsite/view" title="List Site Manager">List Site Manager</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "addlistsite")
                {
            ?>
                <li><a href="<?php echo base_url();?>listsite/add" title="Add List Site">Add List Site</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "viewlistsite")
                {
            ?>
                <li><a href="<?php echo base_url();?>listsite/view" title="View List Site">View List Site</a></li>
            <?
                }
            ?>

            <?php 
                if ($current_main == "projectmanager")
                {
            ?>
                <li><a href="<?php echo base_url();?>project/view" title="Project Manager">Project Manager</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "addproject")
                {
            ?>
                <li><a href="<?php echo base_url();?>project/add" title="Add Project">Add Project</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "viewproject")
                {
            ?>
                <li><a href="<?php echo base_url();?>project/view" title="View Project">View Project</a></li>
            <?
                }
            ?>


            <?php 
                if ($current_main == "jobmanager")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/view" title="Job Manager">Job Manager</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "addjob")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/add" title="Add Job">Add Job</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "viewjob")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/view" title="View Job">View Job</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "importjob")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/import" title="Import Job">Import Job</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "editjob")
                {
            ?>
                <li><a href="#" title="Edit Job">Edit Job</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "importrss")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/importrss" title="Import Jobs from RSS Feed">Import Jobs from RSS Feed</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "viewrss")
                {
            ?>
                <li><a href="<?php echo base_url();?>job/viewrss" title="View RSS Feed">View RSS Feed</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_main == "home")
                {
            ?>
                <li><a href="<?php echo base_url();?>usercp" title="Home">Home</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "dashboard")
                {
            ?>
                <li><a href="<?php echo base_url();?>usercp" title="Dashboard">Dashboard</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "buypoints")
                {
            ?>
                <li><a href="<?php echo base_url();?>usercp/buypoints" title="Buy Points">Buy Points</a></li>
            <?
                }
            ?>
            <?php 
                if ($current_sub == "payment")
                {
            ?>
                <li><a href="<?php echo base_url();?>usercp/payment" title="Payment Transaction">Payment Transaction</a></li>
            <?
                }
            ?>

Solution

  • You need to use full PHP tags.

    Change every instance of <? in your file to <?php and the problem will disappear.

    See this for more information. Note that the real solution here is to use full tags - it may be tempting to enable short open tags but you should avoid this for maximum compatibility and portability.