5

I'm using a Heredoc in order to save a very large block of HTML to a variable so I can send it as an email. However, I keep getting an unexpected end of file syntax error. I've already checked for whitespace before the closing Heredoc tag and other common issues. Any help would be greatly appreciated!

Here's my full code:

<?php

include("init.php");
$email = "matthew910@gmail.com";

$body = <<<HEREDOC
    <!DOCTYPE html>
<html lang="en" style="height: 100%; font-family: sans-serif; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-size: 10px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="https://d2jug8yyubo3yl.cloudfront.net/26999B2F-7C10-4962-918C-E964709E745D/e5d39140-5a3e-4177-9ff1-d7cf74cb6972.jpg">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1">--><!--<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" />--><meta name="description" content="">
<meta name="author" content="">
<title>
        El Patron - Home    

    </title>
<!-- Bootstrap Core CSS - Uses Bootswatch Flatly Theme: http://bootswatch.com/flatly/ --><!-- Custom CSS --><!-- Magnific Popup core CSS file --><!-- Custom Fonts --><!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --><!-- WARNING: Respond.js doesn't work if you view the page via file:// --><!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]--><script src="http://code.jquery.com/jquery-latest.min.js"></script><script src="http://www.minecraftserverland.com/elpatron/js/unslider.js"></script>
</head>
<body id="page-top" class="index" style="height: 100%; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 1.42857143; overflow-x: hidden; margin: 0;" bgcolor="transparent !important">

<div style="min-height: 100%; position: relative; padding-bottom: 45px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">
    <!-- Navigation --><!-- Navigation --><nav class="navbar navbar-default" style="margin-bottom: 0px; margin-right: auto; margin-left: auto; height: 100px; position: fixed; z-index: 10000; top: 0px; background-color: transparent !important; display: none; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; min-height: 60px; text-transform: uppercase; font-family: trajan,'Helvetica Neue',Helvetica,Arial,sans-serif; font-weight: 700; width: 100%; left: 0; border: 0 solid transparent;"><div class="container" style="height: 100px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin-right: auto; margin-left: auto; padding-left: 15px; padding-right: 15px; width: 1170px;">

            <div class="col-lg-12" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; min-height: 1px; padding-left: 15px; padding-right: 15px; float: left; width: 100%;">
                <li class="page-scroll  " style="font-size: 12px; float: right; position: relative; right: 0px; top: 15px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; list-style-type: none;">
                                                    <a href="http://www.minecraftserverland.com/elpatron/register.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; outline: 0;">Login/Register</a>
                                            </li>
        </div>
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header page-scroll" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; float: left; margin-right: 0; margin-left: 0;">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" style="background-color: transparent !important; color: #000 !important; overflow: visible; text-transform: none; -webkit-appearance: button; cursor: pointer; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; float: right; border-radius: 4px; display: none; font-style: normal; font-variant: normal; font-weight: normal; font-size: normal; line-height: normal; background-image: none; margin: 13px 15px 13px 0; padding: 9px 10px; border: 1px solid #1a242f;">
                    <span class="sr-only" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); margin: -1px; padding: 0; border: 0;">Toggle navigation</span>
                    <span class="icon-bar" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: block; width: 22px; height: 2px; border-radius: 1px;"></span>
                    <span class="icon-bar" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: block; width: 22px; height: 2px; border-radius: 1px; margin-top: 4px;"></span>
                    <span class="icon-bar" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: block; width: 22px; height: 2px; border-radius: 1px; margin-top: 4px;"></span>
                </button>
                <a class="navbar-brand" href="http://www.minecraftserverland.com/elpatron/index.php" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; float: left; font-size: 19px; line-height: 1; height: 60px; margin-left: -15px; outline: 0; padding: 18px 15px 19.5px;"><img style="height: 54px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; page-break-inside: avoid; max-width: 100% !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; vertical-align: middle; display: block; border: 0;" src="http://www.minecraftserverland.com/elpatron/img/patronlogo.black.png"></a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse blackbackground" id="bs-example-navbar-collapse-1" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: block !important; overflow-x: visible; padding-right: 15px; padding-left: 15px; border-top-width: 0; border-top-style: solid; -webkit-overflow-scrolling: touch; width: auto; height: auto !important; padding-bottom: 0; overflow: visible !important; margin-right: 0; margin-left: 0; border: transparent;">
                <ul class="nav navbar-nav navbar-right" style="padding-top: 25px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding-left: 0; float: right !important; letter-spacing: 1px; list-style-type: none; margin: 0 -15px 0 0;">
<li class="hidden" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: none !important; float: left;">
                        <a href="#page-top" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;"></a>
                    </li>
                    <li class="page-scroll  " style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; float: left;">
                        <a href="http://www.minecraftserverland.com/elpatron/collection.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;">Collection</a>
                    </li>
                    <li class="page-scroll  " style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; float: left;">
                        <a href="http://www.minecraftserverland.com/elpatron/lifestyle.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;">Lifestyle</a>
                    </li>
                    <li class="page-scroll  " style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; float: left;">
                        <a href="http://www.minecraftserverland.com/elpatron/education.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;">Education</a>
                    </li>
                    <li class="page-scroll  " style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; float: left;">
                        <a href="http://www.minecraftserverland.com/elpatron/professional.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;">Professional</a>
                    </li>
                                                <li class="page-scroll " style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; float: left;">
                        <a href="http://www.minecraftserverland.com/elpatron/cart.php" style="color: #000 !important; background-color: transparent !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; text-decoration: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; position: relative; display: block; line-height: 21px; outline: 0; padding: 19.5px 15px 10px;"><i class="fa fa-shopping-cart" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; line-height: 1; font-family: FontAwesome;"></i> 0  </a>
                    </li>



                </ul>
</div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav><div style="width: 100%; height: 100px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">

</div>

    <div id="login" class="row white-popup mfp-hide text-center" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; text-align: center; display: none !important; position: relative; width: auto; max-width: 400px; min-width: 300px; border-radius: 0px; margin: 20px auto; padding: 35px 20px 25px; border: 3px solid #2c2c2c;" align="center">
                    <h3 style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; orphans: 3; widows: 3; page-break-after: avoid; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family: trajan,'Helvetica Neue',Helvetica,Arial,sans-serif; font-weight: 700; line-height: 1.1; margin-top: 21px; margin-bottom: 10.5px; font-size: 26px; text-transform: uppercase;">
                        Check out our Spotify Playlist
                    </h3>
                    <hr class="dark" style="-moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; height: 1px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; margin-top: 0; margin-bottom: 21px; border-top-color: #ecf0f1; border-top-style: solid; background-image: linear-gradient(to right, #ccc, #333, #ccc); border: 0;">
<img src="http://www.minecraftserverland.com/elpatron/img/spotify.png" style="width: 70%; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; page-break-inside: avoid; max-width: 100% !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; vertical-align: middle; border: 0;">
</div>


        <script style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">
function GetCookie(name) {
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cookie.substring(i,j)==arg)
return "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}

// -->

</script><script style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">
jQuery(window).load(function(){
var visit=GetCookie("COOKIE1");
if (visit==null){
var expire=new Date();


jQuery.magnificPopup.open({
  items: {src: '#login'},type: 'inline'}, 0);


expire=new Date(expire.getTime()+7776000000);
document.cookie="COOKIE1=here; expires="+expire;
}

});
</script><section style="display: block; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 25px 0 50px;"><div class="container" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; margin-right: auto; margin-left: auto; padding-left: 15px; padding-right: 15px; width: 1170px;">

        <div class="col-lg-12 text-center" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; text-align: center; position: relative; min-height: 1px; padding-left: 15px; padding-right: 15px; float: left; width: 100%;" align="center">
            <h2 class="mainheader" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; orphans: 3; widows: 3; page-break-after: avoid; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family: trajan,'Helvetica Neue',Helvetica,Arial,sans-serif; font-weight: 700; line-height: 1.1; font-size: 2.2em; text-transform: uppercase; margin: 0;">
                Welcome
            </h2>
            <hr class="dark" style="-moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; height: 1px; background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; margin-top: 0; margin-bottom: 21px; border-top-color: #ecf0f1; border-top-style: solid; background-image: linear-gradient(to right, #ccc, #333, #ccc); border: 0;">
</div>  



</div>
    <!-- jQuery -->
    <script src="http://www.minecraftserverland.com/elpatron/js/jquery.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script><script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script><!-- Bootstrap Core JavaScript --><script src="http://www.minecraftserverland.com/elpatron/js/bootstrap.min.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script><!-- Plugin JavaScript --><script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script><!--  <script src="js/classie.js"></script> 
    <script src="js/cbpAnimatedHeader.js"></script>
--><!-- Contact Form JavaScript 
    <script src="js/jqBootstrapValidation.js"></script>
    <script src="js/contact_me.js"></script>
    --><!-- Custom Theme JavaScript --><script src="http://www.minecraftserverland.com/elpatron/js/freelancer.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script><!-- Magnific Popup core JS file --><script src="http://www.minecraftserverland.com/elpatron/js/jquery.magnific-popup.js" style="background-color: transparent !important; color: #000 !important; -webkit-box-shadow: none !important; box-shadow: none !important; text-shadow: none !important; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;"></script></section>
</div>
</body>
</html>
HEREDOC;  
echo $email . "<br>";
email($email, "Sponsored Bidding", $body);



?>
mongy910
  • 537
  • 1
  • 5
  • 16
  • 2
    Try and remove whitespace/indent from *after* end of closing `HEREDOC;` line. Dupe of something surly... searching... – ficuscr Jul 23 '15 at 20:28
  • What is in: `init.php` ? – Rizier123 Jul 23 '15 at 20:28
  • @ficuscr you are a lifesaver. Please post an answer so I can accept :) – mongy910 Jul 23 '15 at 20:30
  • 2
    @mongy910 lol you're gonna get downvoted on stack idk why – vijrox Jul 23 '15 at 20:37
  • 1
    Wow I'm a relative newcomer to Stack Overflow and I'm so impressed with Stack's efficiency. Within 15 minutes of posting my question, there have been two correct solutions, my question has been marked as a possible duplicate, and 5 people have interacted with my post. I love this site. – mongy910 Jul 23 '15 at 20:44
  • I ran into a similar problem. After triple checking for whitespace before and after the heredoc, I found the cause to be that I wasn't closing my php `?>` I didn't think it was required in that situation, but putting it there fixed my problem. – TecBrat Sep 19 '17 at 19:39

2 Answers2

8

That specific error can result from white-space / tab indentation on the same line after the closing HEREDOC: Most people catch the opening white-space issue, this one is obviously harder to see.

When in doubt with HEREDOC blocks try and eliminate all possible white-space and indentations.

Possible Dupe: Why do these Heredoc and Nowdoc cause errors?

Community
  • 1
  • 1
ficuscr
  • 6,975
  • 2
  • 32
  • 52
3

You have 2 spaces after the HEREDOC ending statement. Remove trailing spaces after HEREDOC; and it will work.

Turab
  • 182
  • 1
  • 11