tags:

views:

53

answers:

2

Below is the code of viewhistory.php.

    <?php
    foreach($_POST as $value){
     if (empty($value))
     {  echo 1;
      exit();

     }
    }
    //come code;
   //SQL query;
    while($row=mysql_fetch_assoc($result))
    {
     //some code;
      if (!empty($reference))
     {
     $referencetxt=<<<html
    |  Referenced Solution ID:$reference
    html;
     }
     else {
     $referencetxt=" "; 
     }
    $item+=<<<htm
    <hr>
    <span>Solution ID:$productid  $referencetxt</span>
    <xmp>$text</xmp>
    <img src=$imagepath />
    <div align="right">$username $moment</div>
    htm; 
    }
    echo $item;
    ?>

However, I get an error

<br />
<b>Parse error</b>:  syntax error, unexpected $end in

E:\xampp\htdocs\online\viewhistory.php on line 43

when I run it. What is wrong? Is a half bracket missing? But It seems all brackets are paired.

+4  A: 

You've got trailing whitespace after htm; on line 43. Remove it and the parse error will go away.

Also, It looks like you're trying to concatenate the string created in the htm heredoc using the += operator. That should probably be changed to .=.

Asaph
+1 -- Did you paste it into TextMate to find it? Thats how I found it, just didn't get it typed up fast enough. Good catch on the `.=`;
Doug Neiner
@Doug Neiner: Actually, I pasted into vim if you can believe it. Vim didn't color code the end of the heredoc so I knew something was wrong.
Asaph
A: 

I dont think this is the issue but $item+=<<<htm should be $item.=<<<htm.

prodigitalson