BitAndBlack/php-moon-phase

Script fails on live server with arse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in

huet opened this issue · 2 comments

huet commented

parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in moon-phase.php line 10.

I had to rename the file to get it working on my 1and1 server to moon-phase.php5.

I call it via the following wrapper.

file:moonphases-sb.php5

age(), 1 ); $stage = $moon->phase() < 0.5 ? 'Waxing' : 'Waning'; $distance = round( $moon->distance(), 2 ); $miles = round(($distance * 60 * 1.1515)); ``` // $next = gmdate( 'j M Y,G:i:s', $moon->next_new_moon() ); $next = gmdate( 'j M Y', $moon->next_new_moon() ); echo "
    "; echo "
  • Current Moon is: $age days old
  • "; echo "
  • Current Moon is: $stage.
  • "; echo "
  • Next New moon is $next
  • "; echo "
"; ?>

Here is the html I use.

      <article>
        <h2>Current Moon Information</h2>
        <?php include ('../../include/moonphases-sb.php5'); ?>
     </article>

It works correctly on my windows 7 machine using WAmpServer 2.2 with PHP version 5.3.13

But when I try to run it on my hosting server with the following PHP version 5.2.17

I get the above error, have you any idea why searching on google points me to a PHP 4 issue, hence my rename of the script to ensure that works under php5

That is a PHP 4 error. If it works when you rename the file to .php5 then it means your web host defaults to the PHP 4 engine for .php files. You can verify this by running phpversion().

If that is the case, then you need to talk to your web host or even find a new one. PHP 4 reached end of life in 2008 and there is no way it should be running on a production server.

huet commented

Hi Solarissmoke,

I have fixed the PHP issue by adding the following to .htaccess

AddHandler x-mapp-php6 .php

This gives me php version 5.4.16. I need to scan the logs now to see why it is not displaying any thing. But the original error has gone.

So please close this issue. I will investigate the problem now and see if I can solve what it is.