Editor test - JSON error

Editor test - JSON error

xaevoxaevo Posts: 6Questions: 0Answers: 0
edited January 2013 in Editor
Hello! Just bought the editor, and tried your web interface to quickly genereate a test table and sql database, however after installing I keep getting JSON errors.

http://rafteseth.com/todo/test.html

Could anyone point me in the right direction? I have experience with PHP, but I'm not that good at JS...

Thanks for any help!
Werner

Replies

  • essexstephessexsteph Posts: 57Questions: 0Answers: 0
    There's an error in your PHP. When you go to http://rafteseth.com/todo/php/table.test.php directly you see the following error:

    [quote]Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /mounted-storage/home154/sub001/sc16182-ROUK/www/todo/php/table.test.php on line 13[/quote]

    Can you post your PHP file?
  • xaevoxaevo Posts: 6Questions: 0Answers: 0
    Thanks for your quick reply, didn't catch that one - it's one of the files created with the datatables web interface, I'll get on it :)

    [code]
    <?php

    /*
    * Editor server script for DB table test
    * Automatically generated by http://editor.datatables.net/generator
    */

    // DataTables PHP library
    include( "lib/DataTables.php" );

    // Alias Editor classes so they are easy to use
    use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Validate;


    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'test' )
    ->fields(
    Field::inst( 'fornavn' )
    ->validator( 'Validate::required' ),
    Field::inst( 'mellomnavn' ),
    Field::inst( 'etternavn' )
    ->validator( 'Validate::required' ),
    Field::inst( 'tlf' )
    ->validator( 'Validate::minMaxLen_required', array('min'=>8, 'max'=>8 ) )
    )
    ->process( $_POST )
    ->json();

    [/code]
  • xaevoxaevo Posts: 6Questions: 0Answers: 0
    And then it's up and running, now to the task of updating PHP :)
    Thanks for pointing me in the right direction!

    Kind regards
    Werner
  • xaevoxaevo Posts: 6Questions: 0Answers: 0
    Still having some issues with the PHP generated with the Datatables generator - getting PHP errors. As I said, I'm not that great with JS, and have some experience (however limited) with PHP.

    [code]
    <?php

    /*
    * Editor server script for DB table medlemmer1213
    * Automatically generated by http://editor.datatables.net/generator
    */

    // DataTables PHP library
    include( "lib/DataTables.php" );

    // Alias Editor classes so they are easy to use
    use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Validate;


    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'medlemmer1213' )
    ->fields(
    Field::inst( 'fornavn' )
    ->validator( 'Validate::required' ),
    Field::inst( 'mellomnavn' ),
    Field::inst( 'etternavn' )
    ->validator( 'Validate::required' ),
    Field::inst( 'studnr' )
    ->validator( 'Validate::required' ),
    Field::inst( 'telefon' )
    ->validator( 'Validate::required' ),
    Field::inst( 'kjonn' ),
    Field::inst( 'sm' ),
    Field::inst( 'type' ),
    Field::inst( 'utlop' ),
    Field::inst( 'frivillig' ),
    Field::inst( 'aass' ),
    Field::inst( 'stilling' )
    )
    ->process( $_POST )
    ->json();


    [/code]

    Can anyone see the problem here? Getting the following errors:

    PHP Syntax Check: Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in your code on line 10

    PHP Syntax Check: Errors parsing your code

    The weird thing is that this almost look exactly the same as my test setup which works.
    This setup is located here: http://www.rafteseth.com/test/tables.php
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    I'd guess you are using an out dated version of PHP, one which doesn't use namespaces. Perhaps you have v5.2 on the sever? v5.2 was EOL in 2010 and 5.3 / 5.4 is a recommended upgrade by the PHP folks. Editor's PHP classes use a number of the features introduced in 5.3 to present as clean an API as possible.

    Allan
  • xaevoxaevo Posts: 6Questions: 0Answers: 0
    I installed 5.3 a couple of days ago when I bought editor, I can however try to upgrade to 5.4 and check if that works.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    5.3 should be fine. I think there might have been a bug in PHP 5.3.2 that I vaguely remember being a problem, but if you just installed 5.3 recently, you should have a much newer version than that.

    I'd suggest adding `echo phpversion();` just to make sure that your server is running 5.3.

    Allan
  • xaevoxaevo Posts: 6Questions: 0Answers: 0
    Upgraded to 5.4 and that works.
    Thanks for your help!
This discussion has been closed.