Link to home
Start Free TrialLog in
Avatar of it_opswat
it_opswat

asked on

PHP Fatal Error unexpected T_ENDIF

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!!
Avatar of it_opswat
it_opswat

ASKER

I apologize... Line 209 is line 18 up above if anyone had any question about that.
maybe this
 <?php
                                                endif;
                                        } ?>
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
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.
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
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

ASKER CERTIFIED SOLUTION
Avatar of user_n
user_n
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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!!