Announcement

Collapse
No announcement yet.

PHP Parse Error Inside Actinic Not On The Web

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP Parse Error Inside Actinic Not On The Web

    Hi,

    I built a system a while ago that gets the rrp and price and then using this information gives you a how much you save and percentage, now I use this on all our sites and it seems to work perfectly however using the same code ive used on all our actinic sites it seems to give me an error on this one site :s. however it looks fine once I preview on website here is my code:

    Code:
    <actinic:block php="true" >
    $rrp = <actinic:variable name="Product RRP" selectable="false" />;
    $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" />;
    {
    $amountsaved = ($rrp - $rawprice);
    $savepercent = ((($rrp - $rawprice) / $rrp) * 100);
    echo "you save £$amountsaved";
    echo " (".number_format($savepercent,1);
    echo "%)";
    }
    </actinic:block>
    what is odd is as soon as I replace the variable Product RRP with the number that I am inputting into the variable the error goes away meaning it is somthing to do with this variable :s

    Simon
    www.simonstaton.co.uk

    #2
    Make sure that variable Product RRP is of type number and that you don't allow empty values.

    Also, I see that if RRP is ever 0 you will cause a divide by zero error.

    It may be a good idea to have a Condition around all this that checks that Product RRP > 0 and also that Product RRP > ProductPriceRaw.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Hi Norman, thanks for the reply it is already wrapped in a condition which I did not include. where the variable rrp needs to be over 1 for this to take effect. I have also double checked the variable settings and they are set up as you say. I am totally confused to why it is doing this :s
      www.simonstaton.co.uk

      Comment


        #4
        Remove the line

        <actinic:block php="true" >

        and the ending

        </actinic:block>

        You'll then be able to see what PHP is seeing and eyeball parse it.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          It looks fine to me, this is what it looks like without the php block,

          $rrpprice = 49.99; $price = 39.99; { $amountsaved = ($rrpprice - $price); $savepercent = ((($rrpprice - $price) / $rrpprice) * 100); echo "you save £$amountsaved"; echo " (".number_format($savepercent,1); echo "%)"; }

          apart from there being no breaks inbetween the lines it looks fine :s
          www.simonstaton.co.uk

          Comment


            #6
            Put the blocks back. Then try adding

            encoding="perl"


            to each variable.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              ok I tryed that and still the same error :s here is the code with the added blocks with the perl true inside:

              Code:
              <actinic:block if="%3cactinic%3avariable%20name%3d%22RRP%22%20%2f%3e%20%3e%200" encoding="perl" >
              <br>
              <actinic:block php="true" encoding="perl" >
              $rrpprice = <actinic:variable name="RRP" />;
              $price = <actinic:variable name="ProductPriceRaw" selectable="false" />;
              {
              $amountsaved = ($rrpprice - $price);
              $savepercent = ((($rrpprice - $price) / $rrpprice) * 100);
              echo "you save £$amountsaved";
              echo " (".number_format($savepercent,1);
              echo "%)";
              }
              </actinic:block>
              </font>
              </actinic:block>
              www.simonstaton.co.uk

              Comment


                #8

                Comment


                  #9
                  how would I add it too the variable?
                  www.simonstaton.co.uk

                  Comment


                    #10
                    Try this:

                    Code:
                    <actinic:block php="true" >
                    $rrp = <actinic:variable name="Product RRP" selectable="false" encoding="perl" />;
                    $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" encoding="perl" />;
                    {
                    $amountsaved = ($rrp - $rawprice);
                    $savepercent = ((($rrp - $rawprice) / $rrp) * 100);
                    echo "you save £$amountsaved";
                    echo " (".number_format($savepercent,1);
                    echo "%)";
                    }
                    </actinic:block>

                    Comment


                      #11
                      Dont worry got it:

                      <actinic:variable encoding="perl" name="RRP" />

                      however still not working, this is odd as when I preview with the variable it works fine with no errors, maybe an actinic problem? I have compacted the database but still nothing.
                      www.simonstaton.co.uk

                      Comment


                        #12
                        Originally posted by drounding View Post
                        Try this:

                        Code:
                        <actinic:block php="true" >
                        $rrp = <actinic:variable name="Product RRP" selectable="false" encoding="perl" />;
                        $rawprice = <actinic:variable name="ProductPriceRaw" selectable="false" encoding="perl" />;
                        {
                        $amountsaved = ($rrp - $rawprice);
                        $savepercent = ((($rrp - $rawprice) / $rrp) * 100);
                        echo "you save £$amountsaved";
                        echo " (".number_format($savepercent,1);
                        echo "%)";
                        }
                        </actinic:block>
                        Legend that worked
                        www.simonstaton.co.uk

                        Comment


                          #13
                          I added encoding="perl" to the two variables as Norman mentioned.

                          Comment

                          Working...
                          X