• Hi! I need to use comparison operators (greater than and less than) but the plugin reads as > and generates the parse error below:

    Parse error: syntax error, unexpected ‘;’ in /home/meuestil/public_html/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 9

    This line has the following code:

    ‘if ($a > 0.7) {…}’

    Thanks in advance!

    https://wordpress.org/plugins/insert-php/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    Hi Rocker,

    Three things:

    1. Verify you’re using the Text tab and not the Visual tab when editing. The Visual tab would convert < to its HTML entity equivalent.

    2. The error might be the line above or below line 9. It depends on where you start counting.

    3. If the line you quoted is the line with the error, I assume you have other code within the … area on that line. Somewhere in there you have a semi-colon before the PHP parser expects it. Maybe an unclosed quote or parenthesis, but something makes the parser see the ; character before it’s expected.

    Will

    Thread Starter rocker999

    (@rocker999)

    Hello Will, thanks for the reply.

    1. I’m using the text tab, after I save it “converts” the > to “& gt;”

    2. I made some tests, if I have only the code until line 9, there’s no error. When I put that line, it happens.

    3. You’re right, the “…” there’s code inside. I tried to escape the > and < with other plugin, with esc_html() wordpress’ function, [ and ], nothing works… every character I try to put there, become the error instead of the “;”.

    I’d tested the code on an external PHP file direct on browser and it works. The only “;” in there is the “& gt;”.

    There’s some other way to escape/replace those characters?

    Thanks again!

    Plugin Author WillBontrager

    (@willbontrager)

    Rocker, the code between [insert_php] and [/insert_php] should not be escaped or replaced. Leave all characters as they are, the way it works in your external PHP file.

    Insert PHP works by putting the code between [insert_php] and [/insert_php] tags through the PHP eval() function. If you escape or replace any of the valid PHP characters, then you don’t have valid PHP code and you’re likely to encounter errors.

    Will

    Thread Starter rocker999

    (@rocker999)

    I tried to make it simple, my code only has this:

    [insert_php]
    if ($a > $b) {echo “works”;}
    [/insert_php]

    same error.

    Plugin Author WillBontrager

    (@willbontrager)

    This works in a new WordPress installation:

    [insert_php]
    $a = 2; $b = 1;
    if ($a > $b) {echo "works";}
    [/insert_php]

    (Variables initialized so comparison can work.)

    Most likely, a plugin or framework is changing your code.

    If you’re using a framework within which WordPress functions, Insert PHP might not be usable.

    Otherwise, suggest either deactivating all plugins except Insert PHP or creating a new WordPress installation. Then, reactivating or adding your current plugins one at a time, testing Insert PHP between each addition.

    You should be able to determine what’s interfering. Then you can decide which to omit from your installation, the interfering plugin or Insert PHP.

    Will

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘GREATER THAN and LES THAN characters’ is closed to new replies.