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.

T_STRING error with rawurlencode

September 29, 2009 6:57am

Subscribe [1]
  • #1 / Sep 29, 2009 6:57am

    Sacha

    33 posts

    I’m having a really weird error. I’ve narrowed it down to two lines, either one of which causes this error:

    Parse error: syntax error, unexpected T_STRING in /local/data/http…/core/core.functions.php(637) : eval()'d code on line 293

    The two lines are:

    &details;=<?php echo rawurlencode(trim(strip_tags("{description}")));?>
    &location;=<?php echo rawurlencode("{address}");?>

    what’s weird is that a very similar line doesn’t cause any problem:

    &text;=<?php echo rawurlencode(”{title}”);?>

    But wait, it gets even stranger. That code is not even supposed to be executed. It’s inside an if statement, and when the condition is false the error pops up. But when the condition is true and the code does get executed, there’s no error and everything works fine.

    Any clue what’s happening ? To give you more context, I’m trying to add a “add to google calendar” button, and for this I need to encode the content of my fields. “description” is a text zone, and “address” is a text field, and I’ve removed formatting from both.

  • #2 / Sep 29, 2009 9:50am

    ender

    1644 posts

    what kind of conditional?  if it’s a template {if} those don’t prevent execution of what is inside them… basically the entire output is formed and then the template engine decides which output gets seen or thrown away.

  • #3 / Sep 29, 2009 9:58am

    Sacha

    33 posts

    Yes, it was an {if}. Is there any way to prevent execution of something ? Or should I try to replace them with php “if"s ?

  • #4 / Sep 29, 2009 10:35am

    ender

    1644 posts

    using php control statements is the best way to prevent execution of conditional php code.

    I’d suggest assigning your EE custom fields to php variables first, and then testing them to see if they contain what you think they should.

  • #5 / Sep 29, 2009 10:42am

    Sacha

    33 posts

    OK, I’ll look into that. I’m pretty sure I know what the fields contain.. But in any case I want my code to work no matter what people enter in those fields. I’ve noticed that messing with the single and double quotes changes the php error. Maybe I need to escape quotes first before using rawurlencode ?

  • #6 / Sep 29, 2009 10:51am

    Sacha

    33 posts

    By the way, will the code also not be executed if I use php “if” statements but php is parsed on output ?

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

ExpressionEngine News!

#eecms, #events, #releases