WordPress.org

Support

Support » Plugins and Hacks » [Resolved] PHP: Parse error: syntax error, unexpected T_ELSE

[Resolved] PHP: Parse error: syntax error, unexpected T_ELSE

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Jordy Meow

    @tigroumeow

    Thank you! The plugin was rewritten last week-end. Please use the new version 🙂

    Isn’t the new version updated in SVN? I just downloaded the plugin and I’m getting the same error when trying to activate the plugin in WP.

    Plugin Author Jordy Meow

    @tigroumeow

    The last version is 1.0.2. Can you give me the new line?

    I don’t understand because many people are using this plugin (and updated it), and I’m using myself on 4 very different install on WordPress (+ 2 local ones, on Windows and OSX). I have never encountered that issue…

    I just tried updating from 0.54 to 1.0.2 and encountered this.

    Plugin could not be activated because it triggered a fatal error.
    Parse error: syntax error, unexpected ‘else’ (T_ELSE) in …\wp-content\plugins\media-file-renamer\media-file-renamer.php on line 303

    WordPress 3.5.1, PHP 5.4.9, IIS 7.5 on Windows Server 2008 R2 Standard (SP1)

    Plugin Author Jordy Meow

    @tigroumeow

    It’s funny because it is not an unexpected else, and it works for most people. But I might have an idea of what the problem is…

    Line 299:
    <? if ($flagged > 0) { ?>

    Can you please try to replace it with:
    <?php if ($flagged > 0) { ?>

    Please let me know if you can activate the plugin after this change.

    Ah, line 299 looks like it start with <? instead of <?php.

    <? if ($flagged > 0) { ?>

    We posted at the same time. 🙂 Checking…

    Oh, it’s because you’ve used short open tag in PHP one place. Some versions of PHP disables the use of short open tags. Just replace the

    <? if ($flagged > 0) { ?>

    with

    <?php if ($flagged > 0) { ?>

    on line 299 in media-file-renamer.php.

    Yes! The plugin does activate with that correction.

    Plugin Author Jordy Meow

    @tigroumeow

    It seems we all find the issue at the same time 😉 (for some reason it reminds me Fringe, when Walter Bishop and William Bell are working on solving an equation and then end-up with the same result at the same time :p).

    I will include this fix in the next release, of course 🙂

    Plugin Author Jordy Meow

    @tigroumeow

    By the way, it you like the plugin, please rate it, I got a few bad ratings at the beginning and I would love to put them behind since the plugin changed completely since those.

    Inspecting our php.ini file:

    ; short_open_tag
    ; Default Value: On
    ; Development Value: Off
    ; Production Value: Off

    ; This directive determines whether or not PHP will recognize code between
    ; <? and ?> tags as PHP source which should be processed as such. It’s been
    ; recommended for several years that you not use the short tag “short cut” and
    ; instead to use the full <?php and ?> tag combination. With the wide spread use
    ; of XML and use of these tags by other languages, the server can become easily
    ; confused and end up parsing the wrong code in the wrong context. But because
    ; this short cut has been a feature for such a long time, it’s currently still
    ; supported for backwards compatibility, but we recommend you don’t use them.
    ; Default Value: On
    ; Development Value: Off
    ; Production Value: Off
    ; http://php.net/short-open-tag
    short_open_tag = Off

    Plugin Author Jordy Meow

    @tigroumeow

    Super, thanks! I will use that directive from now. Too bad I had this on the whole time!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Resolved] PHP: Parse error: syntax error, unexpected T_ELSE’ is closed to new replies.