0

I think I have a syntax error but I can't spot it, any ideas?

if($infozz['count'] <= $infozz['limit'])
{
mail($infozz['email'], "Your incident report copy!", $bodyz);

echo <<<EOT
<html>

<head>

<title> Summary Report </title>
<link rel="stylesheet" href="http://web.njit.edu/~swp5/assignment/style/style3.css">
</head>

<body>

<div class="header">
Summary Report

</div>

<div class="mess"> 

Type of incident: {$infoz['type']}<br><br>

Date upon entry: {$infoz['date']}<br><br>

Time upon entry: {$infoz['time']}<br><br>

Your account name: {$infoz['reporter']}<br><br>

Your incident ID number: {$infoz['ID']}<br><br>

Your description of the incident: {$infoz['desc']}<br><br>

An email has been sent to your account<br>


</div>

</body>
</html>

EOT;

}
6
  • What is the syntax error message? Commented Oct 1, 2011 at 0:17
  • What error do you get that makes you think it's a syntax error on one of these lines? Commented Oct 1, 2011 at 0:17
  • 1
    Nothing stands out here, but make sure you have nothing, including whitespace on the line before or after EOT; Commented Oct 1, 2011 at 0:18
  • Looks like your echo is ok: codepad.org/nc1eXe3C Commented Oct 1, 2011 at 0:18
  • @Michael, thanks for the tip, that was the error. You can put that as an answer if you want :P Commented Oct 1, 2011 at 0:25

3 Answers 3

2

You cannot have any whitespace before or after the close of a HEREDOC statement. Be sure there is no space before or after your EOT; on this line:

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

Comments

0

Don't echo out html.

PHP and HTML should look like this.

<? 
  if ($something == true) {
?>
  <p>HTML Goes here</p>
<?
  }
?>

6 Comments

Couldn't disagree more. The HEREDOC syntax used in the OP is a perfectly valid method of embedding PHP vars into HTML. Much cleaner than your example.
I can't stand that method. If you want to print a var out do <?= $something; ?>
Your preference is no reason to answer that the OP is doing it wrong.
Opinion isn't an answer; this doesn't solve any "problem" the OP is asking about.
The problem turned out to be whitespace. I don't like the idea of a program not running because of whitespace, if you want to program python, then program python. This is an alternative piece of code that works and is an answer.
|
0

You didn't close your {}'s for your If statement. Also supply an alternate else of else if statement with your HTML in between the statements

5 Comments

The if statement } is closed after the heredoc EOT; on the last line.
You need to put quotes around that string, not process it as a raw string.
Why are you using HEREDOC anyway. It is completely un-necessary
i understand the ending bracket is at the end, I am saying out it before the HTML and than add another else/else if statement. It will work the same as the way you have it now.
@JonahAllibone HEREDOC is a very tidy way of doing what the OP is doing. Several variables embedded in HTML, without function calls mixed in. Sounds like a perfect time for HEREDOC. And no, HEREDOC should not be surrounded by quotes.

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.