views:

113

answers:

2

Hi,

I need some help with this code from PHP Classes, that's supposed to export MySQL to Excel.

I'm getting the following error: Parse error: syntax error, unexpected T_SL in excelwriter.inc.php on line 100

This is line 100:

[Line100] function GetHeader() 
          { 
        $header = <<<EOH 
            <html xmlns:o="urn:schemas-microsoft-com:office:office" 
            xmlns:x="urn:schemas-microsoft-com:office:excel" 
            xmlns="http://www.w3.org/TR/REC-html40"&gt; 

Help? Thank you!

+4  A: 

Heredoc syntax does not allow any trailing whitespaces on the same line after the start (<<<EOH) or end (EOH;) tags.

This error is being caused by the trailing whitespace:

$header = <<<EOH <---- whitespace! remove it.

Remove it, and you should be fine. Be sure to check the end tag as well.

Aron Rotteveel
Thank you. Error changed into "Parse error: syntax error, unexpected $end in excelwriter.inc.php on line 269". Any ideas?
konzepz
This could be caused by many things: short open tags, sudden stop of a PHP class, etc. Without a code example it is hard to say. Judging from the amount of errors in your class, I would suggest looking for something else or write your own.
Aron Rotteveel
Thank you. What do you recommend?
konzepz
You can look for PHP classes that solve this at phpclasses.org. I found this one, http://www.phpclasses.org/browse/package/644.html, might be useful.
Joel Alejandro
A: 

Regarding the error "Parse error: syntax error, unexpected $end in excelwriter.inc.php on line 269" (sorry my reputation does not allow me to make comments to the above reply) I would suggest searching in the same area. The error in question can be encountered when there is an unterminated string och parenthesis for example, be sure that the line with "EOH;" contains only that, and no whitespaces, etc.

kb
An editor with syntax highlighting should be able to give you a clue as to where there is a termination lacking.
kb