We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

My PHP isn’t working

Development and Programming

Charming Nerd's avatar
Charming Nerd
196 posts
14 years ago
Charming Nerd's avatar Charming Nerd

I am converting a non-database driven site to EE. I used some simple PHP in the site to keep navigation current etc. I know that I could do this stuff in a more native EE way, but in the interest of converting this site quickly I was hoping to just use what I have. However, the PHP is not executing probably and I am getting errors. It worked perfectly outside of EE. These are the errors I am getting, followed by the code I am using:

A PHP Error was encountered

Severity: Notice Message: Undefined variable: section Filename: libraries/Functions.php(656) : eval()’d code Line Number: 8

This is the home page template I am using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >

<head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="description" content=""/>
    <meta name="keywords" content=""/>
{embed="includes/head"}

</head>

<body id="home">

<?php $thisPage=('home');?>

{embed="includes/header"}


<div id="wrapper">

    <div id="content-container">
        
        Omitted content for clarity
    
    </div>
    <!-- End Content Container -->
    
    

{embed="includes/footer"}


</div>
<!-- End Wrapper -->


{embed="includes/google"}
</body>
</html>

Here are the embedded header file which is causing the errors:

<div id="header-container">    

    <div id="header">
    
        <a href="/">/_assets/images/logo.png</a>
        
        <ul id="nav">
            <li><a href="/products/elevation-series-panelsclass=current">PRODUCTS</a></li>
            <li><a href="/partners/class=current">PARTNERS</a></li>
            <li><a href="/applications/class=current">APPLICATIONS</a></li>
            <li><a href="/about-us/class=current">ABOUT US</a></li>
            <li><a href="/media/class=current">MEDIA</a></li>
            <li><a href="/contact/class=current">CONTACT</a></li>
        </ul>
        <!-- End Nav -->
        
        
        <?php if ($thisPage=='home') : ?>

        /_assets/images/home/home-header.png
        
        /_assets/images/solar-panel.png
        
        <div id="rotator">
        
            /_assets/images/home/sub-header-1.png
            
            /_assets/images/home/sub-header-2.png
            
            /_assets/images/home/sub-header-3.png
        

        </div>

        <?php endif; ?>

    </div>
    <!-- End Header -->
    
</div>
<!-- End Header Container -->


<?php if ($section=='products') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/products/elevation-series-panels/class=current">Sub Product</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End Products -->


<?php if ($section=='partners') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/partners/class=current">Authorized Partners</a></li>
        <li><a href="/partners/become-a-partner/class=current">Become a Partner</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End Partners -->


<?php if ($section=='applications') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/applications/class=current">Applications</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End Applications -->


<?php if ($section=='about-us') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/about-us/class=current">Overview</a></li>
        <li><a href="/about-us/investors/class=current">Investors</a></li>
        <li><a href="#class=current">Careers</a></li>
        <li><a href="/about-us/faq/class=current">FAQ</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End About Us -->


<?php if ($section=='media') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/media/class=current">Press</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End Media -->


<?php if ($section=='contact') : ?>

<div id="sub-nav-container">
    <ul id="sub-nav">
        <li><a href="/contact/class=current">Contact</a></li>
    </ul>
</div>

<?php endif; ?>

<!-- End Contact -->

[Mod Edit: Moved to the Development and Programming forum]

       
MaxStoun's avatar
MaxStoun
21 posts
14 years ago
MaxStoun's avatar MaxStoun

You are not define $section in header file You will define $section like

<?php 
$section = "{segment_1}"; // for example
?>
       
dept29's avatar
dept29
3 posts
14 years ago
dept29's avatar dept29

Like I said, it worked fine outside of EE. However, I think it is because EE is parsing the PHP before the embeds are being processed. I read that somewhere.

       
MaxStoun's avatar
MaxStoun
21 posts
14 years ago
MaxStoun's avatar MaxStoun

Maybe, outside of EE you have another PHP settings. You will specify error reporting with php.ini

http://php.net/manual/en/function.error-reporting.php

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.