Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP Fatal Error unexpected T_ENDIF

Posted on 2011-09-30
9
Medium Priority
?
579 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

971 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