0

I have invested the good part of 2 days of work trying to solve this problem, when I load the following code on my local machine it works, when I do it to the real site on the cloud it prompts this error.

Parse error: syntax error, unexpected '<'

This happens when it reaches the line 74

73  <?php
74  echo <<<END
75  <p>$fullAddress<br />Phone:   

At the moment my site is broken any help will be apreciated.

code:

<?php
    $addressArray = array(
        $row->fldAddress1,
        $row->fldAddress2,
        $row->fldCity,
        $row->fldCounty,
        $row->fldPostcode
    );

    $fullAddress = implode(", ", array_filter($addressArray));

    $locationAsString = str_replace(array('-',"."), ' ', $row->location);
    $locationAsString = str_replace("ireland", "northern ireland", $locationAsString);

    $addressTeaser = $row->fldCity . ", " . $row->fldCounty . ", " . $row->fldPostcode . ", " . $locationAsString;

    $shopName = $row->fldShopNameTidy;
    $head = substr($shopName,0,1);
    $head = strtoupper($head);

    $storeHasWebsite = ($row->fldShopWebsite != "" && $row->fldShopWebsite != " " && $row->fldShopWebsite != null);
    $storeHasStudio = $row->fldSSStudio;
    $storeHasSnappyStudio = $row->fldStudio;
    $storeHasBusinessPrinting = $row->fldBusiness;
    $storeHasAnyStudio = $storeHasStudio || $storeHasSnappyStudio;
    $storeHasAnyExtras = $storeHasStudio || $storeHasSnappyStudio || $storeHasBusinessPrinting;

    $distance = $row->distance;

    if ($distance < 100) {

?>

<tr>
    <td>

<?php boxLightHeader(); ?>

    <div class="store-details-main-wraper">
        <a id="<?php echo($head); ?>" name="<?php echo($head); ?>" style="display:block;height:0px;width:0px;overflow:hidden;">$head</a>

        <span class="shopnametidy" style="display:none;"><?php echo($row->fldShopNameTidy); ?></span>

        <span class="shoplisttitle"><a href="/stores/<?php echo($row->fldShopNameTidy); ?>"><?php echo($row->fldShopName); ?></a></span>
        <span>
            <?php
                if ($row->distance) {
                    echo("($row->distance miles)<br />");
                }
            ?>
        </span>

        <?php if ($storeHasWebsite) { ?>
            <a href="http://<?php echo($row->fldShopWebsite); ?>" class="web-clickthru-tracking" target="_blank" rel="nofollow">
             <img src="/assets/images/icons/start-shopping-off.png" title="Start Shopping" class="img-swap" />Click &amp; Collect</a><br >
        <?php } ?>

        <div>
             <a href="/stores/<?php echo($row->fldShopNameTidy); ?>/map" class="map-tracking ">
                <img src="/assets/images/icons/map-32-off.png" title="map" class="img-swap" />Map 
            </a>

            <a href="/store-finder/direction/<?php echo($row->fldShopNameTidy); ?>" class="directions-tracking">
                <img src="/assets/images/icons/directions-32-off.png" title="directions" class="img-swap" />Directions
            </a>

            <span class="contactStore details-tracking">
            <img src="/assets/images/icons/store-contact-off.png" title="Contact" class="img-swap" />
            Contact details</span>

            <div class="contact-details-slider" style="height:140px;">
            <div class="contact-details" style="float:left;">
<?php
echo <<<END
<p>$fullAddress<br />Phone:
$row->fldShopTel<br />
$row->fldShopEmail</p>
<hr class="hor-bar-color" />
<p>Get these contact details by:

<span class="sendEmailNew sendLink details-email-tracking" style="font-weight:bold; font-size:1.2em; text-decoration:underline">email</span> or
<span class="sendTextNew sendLink details-text-tracking" style="font-weight:bold; font-size:1.2em; text-decoration:underline">text</span>
<input name="shopId" type="hidden" value="$row->fldID" />
<span class="shopId" style="display:none;">$row->fldID</span></p><hr class="hor-bar-color" />
END;
?>  
            </div>
            <div class="contact-form-placeholder" style="display:none;">foo</div>
            </div>
        </div>

        <div class="extra-services">
<?php
if ($storeHasAnyExtras) {
echo <<<END
<span class="contactStore details-tracking">Specialist services:</span> 
END;
}

if ($storeHasStudio){
echo <<<END
<img src="/assets/images/icons/portrait-studio.jpg" title="Snappy Snaps Studio" />
END;
}

if ($storeHasSnappyStudio){
echo <<<END
<a href="http://www.snappystudio.com/" target="_blank" rel="nofollow"> <img src="/assets/images/icons/snappy-studio-off.png" class="img-swap" title="Snappy Studio" /></a>
END;
}

if ($storeHasBusinessPrinting){
echo <<<END
<a href="http://www.snappysnapsprinting.co.uk/" target="_blank" rel="nofollow"><img src="/assets/images/icons/business-printing-off.png" class="img-swap" title="Business printing" alt="Snappy Snaps business printing" /></a>
END;
}
?>

    <span class="shoplistservice" style="visibility:hidden; font-size:2px;">
        <?php
            if ($storeHasAnyStudio){
                echo "Studio ";
            }
            if ($storeHasBusinessPrinting){
                echo "Business Printing";
            }
        ?>
    </span>

    <span class="shoplistaddress" style="visibility: hidden">
        <?php echo($addressTeaser); ?>
    </span>
    </div>
    </div>
<?php boxLightFooter(); ?>

    </td>
</tr>

<?php } ?>
2
  • That bit of code seems to be working. Are you sure the error is on that line? Commented Jul 10, 2012 at 14:26
  • Hmm... I don't have time to check right now but are you sure that END is not a reserved word? Also, Heredocs can be a pain when it comes to whitespace -- I'd check to make sure you don't have any extra whitespace before/after your terminating token. Commented Jul 10, 2012 at 14:26

3 Answers 3

1

It's possible you have whitespace after <<<END. This will not work. Check that there is absolutely no whitespace at the end of that line.

Either it's being added somehow, or it's possible you're moving between environments where CRLF is used as a newline in code (Windows?) to a machine that uses only CR (Linux?)

Sign up to request clarification or add additional context in comments.

3 Comments

I used Text wrangler on a mac to create the code, then uploaded to a linux server, when I run the code locally on the mac, it works but on the server it does not. Any Ideas?
Thank you For all your help, you guided me to the right places, the problem was the white spaces after the echo<<< but not on my local machine but in the server, it was translated all into a single line, therefore the <<<END was in the same line as everything else. Thank you so much for your help!!!!!!!
This was fixed, by changing the settings from Mozilla Firefox to encode by auto to Binary, this now makes the passing from one file to another with no changes.
0

Your syntax looks fine. You may want to try to use a variable:

$html = <<<END
bla
bla
END;
echo $html;

1 Comment

OH there is another option, thank you very much, I just joined today and I am getting good responses thank you guys from LONDON...
0

echo <<<_END
//Woah, it works!
_END;

I think you tried to use heredoc construction. PHP.net. Here is right syntax, try it

3 Comments

@ametren - (posting against warlord's answer because yours is now deleted) I downvaoted your post, but you'd deleted before I had time to write my comment explaining why... but suggest you read up on heredoc syntax - uk.php.net/manual/en/…
@MarkBaker thanks for the tip, it's not something I'd come across before. It got to -4 with no comments so I deleted it, but I appreciate your effort in correcting my knowledge!
Thanks I will look into that, glad to see solutions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.