PHP Editor error - Parse error: syntax error, unexpected '[' in /var/www/html/md/editor/lib/Database

PHP Editor error - Parse error: syntax error, unexpected '[' in /var/www/html/md/editor/lib/Database

peterbrownepeterbrowne Posts: 5Questions: 1Answers: 0
edited May 19 in Free community support

That's it, error PHP Editor error - Parse error: syntax error, unexpected '[' in /var/www/html/md/editor/lib/Database

This is with a working datatable (no editor function...) on the page and intialising editor with:

include( "../editor/lib/DataTables.php" );
use DataTables\Editor;
$editor = Editor::inst( $db, 'unit', 'unit_pk' )
    ->fields(
        Field::inst( 'unit_name' ),
        Field::inst( 'points' ),
        Field::inst( 'year' )
    )
    ->process( $_POST )
    ->json();

Answers

  • colincolin Posts: 5,590Questions: 0Answers: 976

    Hi @peterbrowne ,

    I think it's because you're not using all the classes. To be sure, could you change

    use DataTables\Editor;
    

    to be

    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    

    I don't think you need them all, but it'll tell us if we're on the right path!

    Cheers,

    Colin

  • peterbrownepeterbrowne Posts: 5Questions: 1Answers: 0
    edited May 22

    Still have the same error:

    "Parse error: syntax error, unexpected '[' in /var/www/html/md/editor/lib/Database.php on line 136 "

    I am using:

    include( "../editor/lib/DataTables.php" );
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    
    $editor = Editor::inst( $db, 'unit', 'unit_pk' )
        ->fields(
            Field::inst( 'unit_name' ),
            Field::inst( 'points' ),
            Field::inst( 'year' )
        )
        ->process( $_POST )
        ->json();
    
  • allanallan Posts: 50,047Questions: 1Answers: 7,403 Site admin

    The error indicates this line, but that is valid PHP.

    What version of PHP are you using please?

    Allan

  • peterbrownepeterbrowne Posts: 5Questions: 1Answers: 0

    PHP Version 5.3.3

  • peterbrownepeterbrowne Posts: 5Questions: 1Answers: 0

    Parse error: syntax error, unexpected '[' in /var/www/html/md/editor/lib/Database.php on line 136

  • allanallan Posts: 50,047Questions: 1Answers: 7,403 Site admin

    That's a really old version now (10 years ago :)) and hasn't seen security updates in a good while.

    Are you able to update to a newer version? Even if its just 5.3.29. I recall having issues with some of the earlier 5.3.x releases before.

    Allan

  • peterbrownepeterbrowne Posts: 5Questions: 1Answers: 0

    Admin is not upgrading, so I'm stuck at 5.3.3

  • jacob.steinbergerjacob.steinberger Posts: 34Questions: 8Answers: 1

    As it's the best you can get with RHEL6 ... may want to update the requirements on the recent version of Editor :(

  • allanallan Posts: 50,047Questions: 1Answers: 7,403 Site admin

    It is possible to install PHP 5.6 using SCL (details), however I agree - I'll mark that the latest version of PHP 5.3 is required.

    @jacob.steinberger Are you also seeing the same error and the same line number?

    Allan

Sign In or Register to comment.