Solved

PHP Fatal Error unexpected T_ENDIF

Posted on 2011-09-30
9
551 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

13 Experts available now in Live!

Get 1:1 Help Now