Solved

PHP Fatal Error unexpected T_ENDIF

Posted on 2011-09-30
9
565 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
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!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding a countdown to HTA 12 92
PHP: Filling Out/Creating a PDF 29 94
How to build a web site 17 49
Ways to Manage 2 Development Projects on Same Section 1 14
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to count occurrences of each item in an array.

685 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