WordPress.org

Ready to get started?Download WordPress

Forums

Media File Renamer
[resolved] PHP: Parse error: syntax error, unexpected T_ELSE (13 posts)

  1. Nararya
    Member
    Posted 1 year ago #

    Just install the plugins and got an error when activate it.

    line 254 <?php else: ?>, take alook line 250 <? if ($flagged > 0): ?> change to <?php if ($flagged > 0): ?>
    Problem solved.

    http://wordpress.org/extend/plugins/media-file-renamer/

  2. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. carestad
    Member
    Posted 1 year ago #

    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.

  4. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    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...

  5. Bradford Luten
    Member
    Posted 1 year ago #

    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)

  6. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  7. Bradford Luten
    Member
    Posted 1 year ago #

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

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

    We posted at the same time. :-) Checking...

  8. carestad
    Member
    Posted 1 year ago #

    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.

  9. Bradford Luten
    Member
    Posted 1 year ago #

    Yes! The plugin does activate with that correction.

  10. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  11. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  12. Bradford Luten
    Member
    Posted 1 year ago #

    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

  13. Jordy Meow
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.