Solved

PHP Fatal Error unexpected T_ENDIF

Posted on 2011-09-30
9
568 Views
Last Modified: 2012-06-21
Hello everyone and thank you ahead of time. I have this error being thrown when I try to load my home page which is built on Drupal... The exact error in the error_log is

[Fri Sep 30 13:03:59 2011] [client 10.0.1.19] PHP Parse error:  syntax error, unexpected T_ENDIF in /var/www/html/sites/all/themes/ourdomain/page.tpl.php on line 209

So here is the code on line 209 plus a little above and below...

<?php echo $productsnav; ?> class="dir"><a style="text-align: center;">Products</a>
                                                <ul class="sub">
                                                        <li<?php echo $metascan; ?>><a class="firstsub" href="/metascan">Metascan</a></li>
                                                        <li<?php echo $md4m; ?>><a href="/metadefender-for-media">MetaDefender for Media</a></li>
                                                        <li<?php echo $md4sa; ?>><a href="/metadefender-secure-access">MetaDefender for Secure Access</a></li>
                                                        <li><a href="/oesis-network">OESIS Network</a></li>
                                                        <li><a href="/oesis-framework">OESIS Framework</a></li>
                                                        <li><a href="/appremover">AppRemover</a></li>
                                                        <li><a href="/cachecleaner">CacheCleaner</a></li>
                                                        <li><a href="/secure-virtual-desktop">Secure Virtual Desktop</a></li>
                                                        <li><a href="/isv-appremover">AppRemover On-Demand</a></li>
                                                        <li><a class="lastsub" href="/isv-secure-virtual-desktop">SVD</a></li>
                                                </ul>
                                                </li>
                                                <li<?php echo $knowledgebase; ?>><a href="/knowledge-base">Knowledge Base</a></li>

                                        <?php
                                                endif;
                                        } ?>
                                        </ul>
                                        <a target="_blank" href="http://www.ourdomain.com/company/events/user-conference-2011">
                                                <div id="banner">
                                                </div>
                                        </a>
                                </div>
                        </div>

Open in new window


If you need me to send more code please let me know... I'm kind of at a loss.

Thanks!!
0
Comment
Question by:it_opswat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 1

Author Comment

by:it_opswat
ID: 36894138
I apologize... Line 209 is line 18 up above if anyone had any question about that.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36894139
maybe this
 <?php
                                                endif;
                                        } ?>
0
 
LVL 6

Expert Comment

by:Dangle79
ID: 36894166
at first glance i'd say, at least from the code provided, you've got conditional close "endif;" on line 18 and no opener "if <argument>" preceding it.

unless it's in more of the code that you didn't paste in you should be good to go if you remove line 18
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 1

Author Comment

by:it_opswat
ID: 36894287
Oops this goes right above where the code starts... I didn't write this code I'm just trying to debug it.


                                                if(in_array('admin', $user_role) || $profilestatus=='OK'):
                                        ?>
                                                        <li<?php echo $productsnav; ?> class="dir"><a style="text-align: center;$
                                                        <ul class="sub">


As you can see that goes in right above teh first line of the posted text above.

I tried removing the endif as well as doing what user_n said... Neither worked.

Removing the endif said something about no $end in the file.
0
 
LVL 9

Expert Comment

by:user_n
ID: 36894346
Try      
if(in_array('admin', $user_role) || $profilestatus=='OK'):
                                        ?>
                                                        <li<?php echo $productsnav; ?> class="dir"><a style="text-align: center;$
                                                        <ul class="sub">

If statement is incorect here it is conditional operator
http://www.tutorialspoint.com/php/php_conditional_operator_examples.htm
You can remove it or live it, but in both cases the syntax is incorrect.
First you can post
<?php (in_array('admin', $user_role) || $profilestatus=='OK'):
                                        ?>
                                                        <li<?php echo $productsnav; ?> class="dir"><a style="text-align: center;$
                                                        <ul class="sub">

of you can leave the if but you should paste breaks {}
http://php.net/manual/en/control-structures.if.php - if statement
http://bg.php.net/manual/es/control-structures.elseif.php - endif statement
0
 
LVL 1

Author Comment

by:it_opswat
ID: 36894366
Damnit... It didn't copy it all. I apologize. Here it is all in one chunk... is there any way you can highlight what's wrong and the change you implemented. I'm positive you're onto this user_n it's just I'm a sysadmin trying to fix something while the web dev is out... So I'm kind of lost. I don't really know PHP at all.

 if(in_array('admin', $user_role) || $profilestatus=='OK'):
                                        ?>
                                                        <li<?php echo $productsnav; ?> class="dir"><a style="text-align: center;">Products</a>
                                                        <ul class="sub">
                                                                <li<?php echo $metascan; ?>><a class="firstsub" href="/metascan">Metascan</a></li>
                                                                <li<?php echo $md4m; ?>><a href="/metadefender-for-media">MetaDefender for Media</a></li>
                                                                <li<?php echo $md4sa; ?>><a href="/metadefender-secure-access">MetaDefender for Secure Access</a></li>
                                                                <li><a href="/oesis-network">OESIS Network</a></li>
                                                                <li><a href="/oesis-framework">OESIS Framework</a></li>
                                                                <li><a href="/appremover">AppRemover</a></li>
                                                                <li><a href="/cachecleaner">CacheCleaner</a></li>
                                                                <li><a href="/secure-virtual-desktop">Secure Virtual Desktop</a></li>
                                                                <li><a href="/isv-appremover">AppRemover On-Demand</a></li>
                                                                <li><a class="lastsub" href="/isv-secure-virtual-desktop">Secure Virtual Desktop On-Demand</a></li>
                                                        </ul>
                                                        </li>
                                                        <li<?php echo $knowledgebase; ?>><a href="/knowledge-base">Knowledge Base</a></li>

                                                <?php
                                                        endif;
                                                } ?>
                                        </ul>

Open in new window

0
 
LVL 9

Accepted Solution

by:
user_n earned 500 total points
ID: 36894389
I hope that this will help

 if(in_array('admin', $user_role) || $profilestatus=='OK'){
                                        ?>
                                                        <li<?php echo $productsnav; ?> class="dir"><a style="text-align: center;">Products</a>
                                                        <ul class="sub">
                                                                <li<?php echo $metascan; ?>><a class="firstsub" href="/metascan">Metascan</a></li>
                                                                <li<?php echo $md4m; ?>><a href="/metadefender-for-media">MetaDefender for Media</a></li>
                                                                <li<?php echo $md4sa; ?>><a href="/metadefender-secure-access">MetaDefender for Secure Access</a></li>
                                                                <li><a href="/oesis-network">OESIS Network</a></li>
                                                                <li><a href="/oesis-framework">OESIS Framework</a></li>
                                                                <li><a href="/appremover">AppRemover</a></li>
                                                                <li><a href="/cachecleaner">CacheCleaner</a></li>
                                                                <li><a href="/secure-virtual-desktop">Secure Virtual Desktop</a></li>
                                                                <li><a href="/isv-appremover">AppRemover On-Demand</a></li>
                                                                <li><a class="lastsub" href="/isv-secure-virtual-desktop">Secure Virtual Desktop On-Demand</a></li>
                                                        </ul>
                                                        </li>
                                                        <li<?php echo $knowledgebase; ?>><a href="/knowledge-base">Knowledge Base</a></li>

                                                <?php
//                                                        endif;
                                                } ?>
                                        </ul>
0
 
LVL 1

Author Comment

by:it_opswat
ID: 36894416
I now get this...

Parse error: syntax error, unexpected $end in /var/www/html/sites/all/themes/opswatportal/page.tpl.php on line 305

Which there isn't a lin305... It ends at 304
0
 
LVL 1

Author Closing Comment

by:it_opswat
ID: 36894652
While what you posted didn't fix my problem... You were correct in everything you posted so I'm giving it to you!!

The problem was way up higher in the code a <? was missing <?php so it was throwing an error.

Thanks a lot!!
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

623 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