0

I am using NGINX and PHP 5.6 and cannot seem to debug this error after an upgrade. My error log reads:

2015/12/29 11:57:56 [error] 928#0: 20485 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected '}' in /var/www/magento/htdocs/pub/become/wp-content/themes/become/index.php on line 81" while reading response header from upstream, client: 83.110.226.45, server: sss.uat...com, request: "GET /become/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/sss.uat.*..com.sock:", host: sss.uat.***..com"

And this is my PHP

<?
if($sss_article_featuretitle==""){?>
    <?php echo mb_strimwidth(the_title(), 0, 40, '...'); ?>
<?php } else { //line 81
    echo $sss_article_featuretitle;
}
?>

The PHP 5.6 docs and some searching does not say why this query is no obsolete.

Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64
TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209
  • can you post more of your php? there must be something else happening.. – Clay Dec 29 '15 at 12:09
  • You could change the if syntax to be like this ``...``...`` read more here http://php.net/manual/en/control-structures.alternative-syntax.php – Clay Dec 29 '15 at 12:11
  • aww man, if I'm right I'll post as an answer so Andrii doesn't gank my hard earned internet points – Clay Dec 29 '15 at 12:18

2 Answers2

1

Remove all excess open/close tags:

<?php
if ($sss_article_featuretitle=="") {
    echo mb_strimwidth(the_title(), 0, 40, '...');
} else {
    echo $sss_article_featuretitle;
}
?>

Update: Try to change it like this:

http://php.net/manual/en/language.basic-syntax.phpmode.php

<?php if ($sss_article_featuretitle==""): ?>
  <?php echo mb_strimwidth(the_title(), 0, 40, '...'); ?>
<?php else: ?>
  <?php  echo $sss_article_featuretitle; ?>
<?php endif; ?>

Also make sure you don't use short open tag <?, which is not a good practice and is probably disabled in PHP settings, so should be turned on by short_open_tag directive in your php.ini file.

http://php.net/manual/en/language.basic-syntax.phptags.php

Andrii
  • 329
  • 2
  • 8
  • I don't have this option because other files that this programmer has built have large HTML gaps between conditionals. – TheBlackBenzKid Dec 29 '15 at 12:08
  • The issue was due to short_open_tag, we swapped servers and the host has disabled them and now our entire application is not working on our UAT environment. Shame. I like short tags personally – TheBlackBenzKid Dec 29 '15 at 12:24
  • I also like it, but it causes troubles sometimes, like in this case :) – Andrii Dec 29 '15 at 12:25
0

Check that you have short_open_tags enabled. It looks like that first PHP part is } else {. I think that it was maybe removed in PHP 5.6 or at least deprecated.

Can you upload phpinfo somewhere?

martin.malek
  • 2,166
  • 2
  • 19
  • 31