I can't figure out where this error is located. Line 1 is <?php also i'm using a phpIDE app and its not showing any errors / missing braces.

PHP Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in /home/ratemy/public_html/kernel/parser.php(190) : eval()'d code on line 1

code lines from 167 - 200... line 190 is marked below.

# Format replaced vars
    function do_format($value,$s) {
            global $en;
            $value = (isset($en[$value]) ? $en[$value] : @constant($value));
            $i = strtolower($s);
            if (strpos($i,'echo') || strpos($i,'define')) {
                    $value = str_replace('"','`',$value);
                    $value = str_replace(chr(39),'`',$value);
                    }
            return $value;
            }

# Execute template block
    function exec_block($start, $end, $jump = -2) {
            $this->tpi = $start - 1;
            while ($this->tpi < $end) {
                    $s = $this->templ_read();
                    $this->s = $this->template_replace_vars($s);
                    if ($this->act[$this->tpi] == 'continue_loop') return false;
                    if ($this->act[$this->tpi] == 'break_loop') {
                            $this->cancel_loop = true;
                            return false;
                            }
                    eval('$this->'.$this->act[$this->tpi].'();'); // LINE 190
                    }
            if ($jump != -2)
                    $this->tpi = $jump;
            }

# Echo a line
    function do_print() {
            echo $this->s;
            }

... snippet

there is more too the file is there a way I can figure out where this error is actually at?

link|improve this question

79% accept rate
3  
It's in line 190, which obviously contains a call to eval() – knittl Jan 11 at 12:21
can you post any of the code from /home/ratemy/public_html/kernel/parser.php? – jere Jan 11 at 12:32
@knittl i've edited the question to show line 190 – acctman Jan 11 at 16:00
@jere see changes above, thanks. – acctman Jan 11 at 16:01
did you try removing those () in eval('$this->'.$this->act[$this->tpi].'();');? the error says there's an unexpected parentheses – jere Jan 11 at 16:08
show 4 more comments
feedback

2 Answers

up vote 1 down vote accepted

If you want to call a function the name of which is given by $this->act[$this->tpi], use this:

call_user_func(array($this, $this->act[$this->tpi]));

Don't do eval, it is evil.

link|improve this answer
feedback

knittl wrote : It's in line 190, which obviously contains a call to eval()" 1 min ago

Knittl is correct - the error is on that line in your file. "eval()'d code on line 1" means that the error is on the first line of the code that is being eval()'d on line 190 of file parser.php

Put this on the line before line 190: echo '$this->'.$this->act[$this->tpi].'();';

and it will show you the code that is being eval'ed that is causing the error.

link|improve this answer
I've edited my question to include line 190 – acctman Jan 11 at 16:01
The answers still the same - the error is in the code being eval'ed. Not in the code that is calling the eval. – Danack57 Jan 12 at 0:28
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.