ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

php error with simple 'if' statement

August 05, 2012 11:16am

Subscribe [4]
  • #1 / Aug 05, 2012 11:16am

    feisnamara

    8 posts

    Hi there,

    I’m quite new using php. I have a php error from using a simple ‘if’ statement:

    A PHP Error was encountered

    Severity: User Warning

    Message: Invalid EE Conditional Variable: {if ""_4 !=""}

    Filename: libraries/Functions.php

    Line Number: 2843

    Here is my code:

    {exp:channel:entries channel="news_blog" limit="10" orderby="date" sort="desc" backspace="218" disable="category_fields|categories|member_data|pagination"}
            
     {if link_group_name !=""}
     <h2>{link_group_name}</h2>
    <p> {/if}<br />
     {if links !=""}<br />
     {links}<br />
     {/if}</p>
    
    <p> {if link_group_name_2 !=""}<br /></p><h2>{link_group_name_2}</h2>
    <p> {/if}<br />
     {if links_2 !=""}<br />
     {links_2}<br />
     {/if}<br />
     <br />
     {if link_group_name_3 !=""}<br /></p><h2>{link_group_name_3}</h2>
    <p> {/if}<br />
     {if links_3 !=""}<br />
     {links_3}<br />
     {/if}</p>
    
    <p> {if link_group_name_4 !=""}<br /></p><h2>{link_group_name_4}</h2>
    <p> {/if}<br />
     {if links_4 !=""}<br />
     {links_4}<br />
     {/if}</p>
    
    <p> {/exp:channel:entries}

    I thought it might be because I didn’t have allow php turned on in the templat preferences but I have turned it on and its still the same. I would be greatful for suggestions.

    Many Thanks

  • #2 / Aug 05, 2012 11:20am

    feisnamara

    8 posts

    I’ve changed my code a bit to call the correct channel and a few other changes but I’m still getting the same error message:

    {exp:channel:entries channel="links" limit="1" disable="category_fields|categories|member_data|pagination"}
            
     {if link_group_name !=""}
     <h2>{link_group_name}</h2>
    <p> {/if}<br />
     {if links !=""}<br />
     {links}<br />
     {/if}</p>
    
    <p> {if link_group_name_2 !=""}<br /></p><h2>{link_group_name_2}</h2>
    <p> {/if}<br />
     {if links_2 !=""}<br />
     {links_2}<br />
     {/if}<br />
     <br />
     {if link_group_name_3 !=""}<br /></p><h2>{link_group_name_3}</h2>
    <p> {/if}<br />
     {if links_3 !=""}<br />
     {links_3}<br />
     {/if}</p>
    
    <p> {if link_group_name_4 !=""}<br /></p><h2>{link_group_name_4}</h2>
    <p> {/if}<br />
     {if links_4 !=""}<br />
     {links_4}<br />
     {/if}</p>
    
    <p> {if link_group_name_5 !=""}<br /></p><h2>{link_group_name_5}</h2>
    <p> {/if}<br />
     {if links_5 !=""}<br />
     {links_5}<br />
     {/if}</p>
    
    <p> {if link_group_name_6 !=""}<br /></p><h2>{link_group_name_6}</h2>
    <p> {/if}<br />
     {if links_6 !=""}<br />
     {links_6}<br />
     {/if}</p>
    
    <p> {/exp:channel:entries}

     

  • #3 / Aug 05, 2012 11:45am

    feisnamara

    8 posts

    is this a bug? https://support.ellislab.com/bugs/detail/17989/

    I see someone has had a similar problem and that its a bug? If so, do I folow the direction as noted under it on that page?

    Thanks

  • #4 / Aug 06, 2012 3:07pm

    Shane Eckert

    7174 posts

    Hey feisnamara,

    I am sorry to hear you have run into this issue.

    It’s odd that you are getting

    {if ““_4 !=”“}

    . It’s as if the first part of the variable is blanked out and leaving behind the _4. It might be related to the bug, but the behavior is a tad different.

    Can you tell me what version of ExpressionEngine you are currently using?

    Please give the fix a try and let me know the results. If it fixes your problem, then great. It’s really odd that the others are ignored, but _4 is called out. Why does it seem to work (so not the bug) for some but not the other (maybe it is the bug).

    If that does not work for you, we can go from there. It’s worth ruling it out

    Thank you,

  • #5 / Aug 29, 2012 2:58pm

    mazzal

    87 posts

    Hi Shane,

    Thank you for your reply.

    I tried the bug fix but it didn’t work. I’m using EE v2.5.2 - Build Date: 20120606

    Do you have any more ideas why this is happening? It is rather strange!

    Thanks for your help

  • #6 / Aug 30, 2012 11:42am

    Shane Eckert

    7174 posts

    Hello,

    I checked the source code and found a helpful comment.

    // There is a partial variable match being done
    // because they are doing something like segment_11
    // when there is no such variable but there is a segment_1
    // echo  $x[$j]."\n
    \n";
    trigger_error('Invalid EE Conditional Variable: '.
    $matches[0][$i], 
    E_USER_WARNING);

    Can you check to make sure that links_4 is really present?

    Thank you,

  • #7 / Aug 30, 2012 12:30pm

    feisnamara

    8 posts

    Hi Shane,

    Thanks again for your help.

    I can confirm that links_4 is there, I have just double checked (I have attached a screenshot).

    Perhaps its a different bug? Have you heard of anyone having a similar problem?

    I really have no idea!

    Thanks

  • #8 / Aug 31, 2012 10:20am

    Shane Eckert

    7174 posts

    Hey feisnamara,

    Please be on the lookout for an email from EllisLab.

    Thank you,

  • #9 / Oct 01, 2012 11:18am

    Kevin Smith

    4784 posts

    Hi feisnamara,

    Just wanted to check to see if you ever got that email from us. If you still need help, let me know and we’ll send that email again!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases