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 When Commenting

July 09, 2012 12:50am

Subscribe [2]
  • #1 / Jul 09, 2012 12:50am

    tabboy

    24 posts

    I have the following code in a comment entries tag

    {if logged_in_member_id == author_id}
      <span class="reply"><a href="http://{path=Bands/Delete_Comment/{segment_3}/{comment_id}}">Delete</a></span>
    {if:elseif logged_in_member_id != author_id}
       <span class="reply">a href="#">Reply</a></span>
     {/if}

    If I then modify the condition to the following I get a PHP error

    {if logged_in_member_id == author_id && logged_in}

    A PHP Error was encountered

    Severity: Notice
    Message: Use of undefined constant TRUEFALSE - assumed ‘TRUEFALSE’
    Filename: libraries/Functions.php(680) : eval()‘d code
    Line Number: 193
    A PHP Error was encountered

    Severity: Notice
    Message: Use of undefined constant TRUEFALSE - assumed ‘TRUEFALSE’
    Filename: libraries/Functions.php(680) : eval()‘d code
    Line Number: 195


    Any ideas?  Is Functions.php(680) the line number of the function?  It refers to the following if it is…

    function evaluate($str)
     {
      return eval('?'.'>'.$str.'<?php ');  
     }

     

  • #2 / Jul 09, 2012 1:02am

    tabboy

    24 posts

    I changed my if statement to this and now it does what I want.  Just curious why it’s returning a PHP error…

    {if logged_out}
       <span class="reply">a href="#">Reply</a></span>
    {if:elseif logged_in_member_id == author_id}
         <span class="reply"><a href="http://{path=Bands/Delete_Comment/{segment_3}/{comment_id}}">Delete</a></span>
    {if:elseif logged_in_member_id != author_id}
        <span class="reply">a href="#">Reply</a></span>
    {/if}
  • #3 / Jul 10, 2012 1:48pm

    Kevin Smith

    4784 posts

    Hi tabboy,

    I suspect the PHP error was thrown because this:

    {if logged_in_member_id == author_id && logged_in}

    is redundant since logged_in_member_id won’t return the author’s ID if the user viewing the page isn’t logged in. Make sense? In other words, this statement:

    {if logged_in_member_id == author_id}

    will already evaluate false if the viewer isn’t logged-in. Your first code sample should do what you want. Are you getting unexpected results?

  • #4 / Jul 10, 2012 8:01pm

    tabboy

    24 posts

    Yes that makes perfect sense!  Now I feel like an idiot ha ha Thanks for you help I can sleep better at night now 😊  Please close the call.

  • #5 / Jul 13, 2012 10:25am

    Shane Eckert

    7174 posts

    Hello tabboy,

    I am glad to see that Kevin was able to help you out!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases