Click to See Complete Forum and Search --> : unexpected $ with fpdf


gnarf32
08-24-2005, 04:25 AM
Hi there guys, i got the following problem. Maybe you can help me:

I'd like to write a PDF with some HTML & PHP code. So i figured i'd use fpdf. Here is a a little example of the code:

----------------------------------------------------
<?

$html="";
$html=<<<PDF_BODY
<table border="0" cellspacing="0" cellpadding="0" width="600">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="10" width="100%">
<tr>
<td width="100%" valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="title"><font class="title">{$productlang['name']}</font><td>
</tr>
<tr>
<td height="10"></td>
</tr>
<tr>
<td>{$description}</td>
</tr>
PDF_BODY;
if ($properties&&{$product['has_properties']}){
$html.=<<<PDF_BODY
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td nowrap><font>{$_TEXT['techdata']}:</font></td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
<tr>
<td><img src="_images/spacer.gif" border="0" width="1" height="5"></td>
</tr>
PDF_BODY;


// create pdf
$pdf=new PDF();
$pdf->AddPage();
$pdf->SetMargins(20,20,20,20);
$pdf->SetFont('Arial','', 10);
$pdf->SetTextColor(0,0,0);
$pdf->SetXY(20,50);
$pdf->Ln(35);
$pdf->WriteHtml($html);
$pdf->Ln(25);

$pdf->Output();

?>

The actual script is bigger but it's too long to post it here. Anyway. Everytimer i try to run the script i get this msg:

Parse error: parse error, unexpected $ in /web/www/eyemedia_ch/clients/public_html/candyhoover.ch/modules/mo_products_print.php on line 177

with line 177 being the last line of the script.

Now i know that this error usually describes a missing { or } or whatever but i double and triple checked the code. Did anyone expirience this problem before?

Thanks in advance for any help

arto
08-24-2005, 06:22 AM
This one is not closed: if ($properties&&{$product['has_properties']}){Also, don't put { } around variables in if expression. So: if ($properties && $product['has_properties']) {
...
}Arto

gnarf32
08-24-2005, 10:19 AM
thanks for the response. the if clause in the original script is closed. it was just a snipped. anyway. the matter is resolved now. forgot to set some "body_pdf;"s. thanks anyway

cheers

close thread