Title: PHP: Parse error: syntax error, unexpected T_ELSE
Last modified: August 20, 2016

---

# PHP: Parse error: syntax error, unexpected T_ELSE

 *  Resolved [Nararya](https://wordpress.org/support/users/nararya/)
 * (@nararya)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/)
 * 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/](http://wordpress.org/extend/plugins/media-file-renamer/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318743)
 * Thank you! The plugin was rewritten last week-end. Please use the new version
   🙂
 *  [carestad](https://wordpress.org/support/users/carestad/)
 * (@carestad)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318744)
 * 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](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318745)
 * 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…
 *  [Bradford Luten](https://wordpress.org/support/users/blluten/)
 * (@blluten)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318750)
 * 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](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318751)
 * 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.
 *  [Bradford Luten](https://wordpress.org/support/users/blluten/)
 * (@blluten)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318752)
 * Ah, line 299 looks like it start with <? instead of <?php.
 * <? if ($flagged > 0) { ?>
 * We posted at the same time. 🙂 Checking…
 *  [carestad](https://wordpress.org/support/users/carestad/)
 * (@carestad)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318753)
 * 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**.
 *  [Bradford Luten](https://wordpress.org/support/users/blluten/)
 * (@blluten)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318754)
 * Yes! The plugin does activate with that correction.
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318755)
 * 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](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318756)
 * 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.
 *  [Bradford Luten](https://wordpress.org/support/users/blluten/)
 * (@blluten)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318757)
 * 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](http://php.net/short-open-tag)
   short_open_tag = Off
 *  Plugin Author [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * (@tigroumeow)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318758)
 * 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 ‘PHP: Parse error: syntax error, unexpected T_ELSE’ is closed to new replies.

 * ![](https://ps.w.org/media-file-renamer/assets/icon-256x256.png?rev=2791577)
 * [Media File Renamer: Rename for better SEO (AI-Powered)](https://wordpress.org/plugins/media-file-renamer/)
 * [Support Threads](https://wordpress.org/support/plugin/media-file-renamer/)
 * [Active Topics](https://wordpress.org/support/plugin/media-file-renamer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/media-file-renamer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/media-file-renamer/reviews/)

 * 12 replies
 * 4 participants
 * Last reply from: [Jordy Meow](https://wordpress.org/support/users/tigroumeow/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/php-parse-error-syntax-error-unexpected-t_else/#post-3318758)
 * Status: resolved