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.

Parse error after Upgrade to 2.52

July 22, 2012 8:59am

Subscribe [2]
  • #1 / Jul 22, 2012 8:59am

    Unbridled Books

    16 posts

    Hi,

    I just completed an upgrade from 2.20 to 2.52 and I was getting the error message:

    Parse error: syntax error, unexpected ‘&’ ... fuctions.php(680)

    I narrowed the problem down to a string of PHP code in the template.  I would just like to know the best recommendation for replacing this code with something more current.

    {if author_prev1_link != ""AND author_prev1_name !="<?php echo $str3; ?>"} 
      <a >{author_prev1_image}</a>
    {/if}

    I have a few statements of this kind in there and all of them must be commented out for the page to run.  It is something in the PHP statement.  Any help would be appreciated.

    Thanks
    Warren Austin

  • #2 / Jul 23, 2012 5:50pm

    Dan Decker

    7338 posts

    Hi Warren,

    I’d be happy to give some ideas, what context is the PHP used in?

    What are you checking with $str3 ?

    Do you have another means of accessing that value?

    Cheers,

  • #3 / Jul 24, 2012 9:24am

    Unbridled Books

    16 posts

    Hi Dan,

    Thanks for looking at this for me.

    The $str3 is a variable that I’ve assigned while looping through a related channel.  I am displaying information about a particular book, but at one point, I need to display other books written by the same author (information found in the author channel instead of the book channel).  So I assign the author’s previous books to variables and pull them out to display on the book page currently open.

    The PHP is only used to store the variable and then echo it when I’m back on the book page.

    It has worked fine with this setup until the upgrade to 2.52.  I don’t see anything wrong with the code, so I’m thinking maybe it’s been deprecated or something.

    Thanks
    Warren

  • #4 / Jul 25, 2012 11:15am

    Dan Decker

    7338 posts

    Hi Warren,

    Do you mind showing me the full templates involved? I think there may be a better way using native relationships and embed templates/embed variables and we can just eliminate the PHP all together.

    In the meantime though, let’s troubleshoot this loop. If you take the PHP out of the EE conditional, does it echo what you expect to see?

    What stage are you parsing PHP in the template? Have you double checked that the template’s PHP settings survived the update process?

    Also, try your code like this:

    {if {author_prev1_link} != "" && {author_prev1_name} != "<?= $str3; ?>"} 
      <a >{author_prev1_image}</a>
    {/if}

    Note the braces. I changed the PHP to shorthand just to save you some space 😉

    Cheers,

  • #5 / Jul 25, 2012 12:47pm

    Unbridled Books

    16 posts

    Dan,

    When I first wrote the code, about 2 years ago on Version 1.67, I tried the embedded variables and I couldn’t get it to work.  That’s why I went to the PHP.

    I tried the changes you recommended and the error that it gives now is:

    Parse error: syntax error, unexpected T_IS_NOT_EQUAL in /home/jewelzan/public_html/ubb/eecontrol/expressionengine/libraries/Functions.php(680) : eval()‘d code on line 260

    I did some digging and determined that it may have something to do with some of the custom fields I’ve created for this.  The author_prev1_name field works fine in the loop, but if I put author_prev2_name or anything else, it gives the message above.

    I’m going to try to fix this on my own because I’ll learn more that way.  Whatever I find, I’ll let you know and finish off this post.

    Thanks
    Warren Austin

  • #6 / Jul 26, 2012 1:24pm

    Dan Decker

    7338 posts

    Hey Warren,

    I’m going to try to fix this on my own because I’ll learn more that way.

    I sincerely applaud that attitude! However, don’t hesitate to ask questions, ever.

    What kind of field is {author_prev2_name} ? That may have something to do with the way it’s behaving. What’s different about it vs. the field that doesn’t cause the error?

    Cheers,

  • #7 / Jul 26, 2012 6:48pm

    Unbridled Books

    16 posts

    Hi again,

    Sorry to throw you off the scent, but the issue with author_prev2_name was more my own doing.  I had a syntax error in one of the lines, so that was a red herring.

    But, on the plus side, I did get it working.  The first thing I noticed was the the template preferences were set to “output” (and always have been).  But it looks like the 2.52 documentation says that it needs to be set to “input” to do the kind of PHP that I was trying to do.  The “input” setting didn’t work for me because there were too many other PHP statements in the template that didn’t work after I changed it.  So, I wound up rewriting the if statement in PHP instead.

    So, the code went from:

    {if author_prev1_link != "" AND author_prev1_name !="<?php echo $str3; ?>"} 
    <a >{author_prev1_image}</a>
    {/if}
    {if author_prev2_link != "" AND author_prev2_name !="<?php echo $str3; ?>"}
    <a >{author_prev2_image}</a>
    {/if} etc…

    to…

    <?php 
    if ("{author_prev1_name}" !=  $str3 && "{author_prev1_link}" != ""){
      print "<HTML>"; print "<a ><img  ></a>";
    }
    if ("{author_prev2_name}" !=  $str3 && "{author_prev2_link}" != ""){
      print "<HTML>"; print "<a ><img  ></a>"; 
    etc…}

    It works fine now.  Thanks for your help with this and I hope it helps others that might run across this problem.

    Warren Austin

  • #8 / Jul 27, 2012 5:41pm

    Dan Decker

    7338 posts

    Hi Warren,

    I’m glad to see you’ve got it working!

    I’ll move this over to Community Help for posterity. Thanks for sharing!

    Cheers,

  • #9 / Oct 23, 2012 4:15am

    Creative Spirits

    40 posts

    Thank you Warren!

    I had the same error message when upgrading from 2.4 to 2.5.3, and a similar PHP code:

    {if title != "<?php echo $title; ?>"}
       <li><a href="http://{title_permalink={segment_1}/{segment_2}}">{title}</a></li>
    {/if}

    Rewriting this to

    <?php if ( "{title}" != $title ) { ?>
       <li><a href="http://{title_permalink={segment_1}/{segment_2}}">{title}</a></li>
    <?php } ?>

    fixed it.

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

ExpressionEngine News!

#eecms, #events, #releases