Undefined property 'name' / unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING

Undefined property 'name' / unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING

agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
edited October 2012 in Editor
Hello,
I'm trying to deployed on a just generated Editor example of DataTables, but I'm unable to make it work.

[1]
In my local environment, I'm receiving the following error when I click on New, enter record information and then hit Update button:
"
Notice: Undefined property: DataTables\Editor\Field::$name in C:\SkyDrive\webapps\htdocs\DataTables\php\lib\Editor\Editor.php on line 319
{"id":-1,"error":"","fieldErrors":[{"name":null,"status":null}],"data":[]}
"

[2]
In my live environment (http://a4enterprise.com/DataTables/exp_budget_expenses193.html) I'm receiving a different error, when I just try to load the same page:

"
DataTables warning (table id = 'exp_budget_expenses193'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error. "

And the following error is triggered on the HTML Response (FF FireBug's Net XHR section)
"
Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/a4enterp/public_html/DataTables/php/table.exp_budget_expenses193.php on line 13
"

Can you please guide on what am I missing?

I have PHP 5.4 on both environments, tried the database connection on both and it works just fine

Replies

  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    Any comment on this one?
    Thanks
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Can you show us your file `table.exp_budget_expenses193.php` ?

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Here:
    [code]
    <?php

    /*
    * Editor server script for DB table exp_budget_expenses193
    * 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, 'exp_budget_expenses193' )
    ->fields(
    Field::inst( 'master_id' ),
    Field::inst( 'user_id' ),
    Field::inst( 'debtor' )
    ->validator( 'Validate::required' ),
    Field::inst( 'type' )
    ->validator( 'Validate::required' ),
    Field::inst( 'category' )
    ->validator( 'Validate::required' ),
    Field::inst( 'creditor' )
    ->validator( 'Validate::required' ),
    Field::inst( 'amount' )
    ->validator( 'Validate::required' ),
    Field::inst( 'due_date' )
    ->validator( 'Validate::dateFormat_required', 'D, j M y' )
    ->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
    ->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
    Field::inst( 'bill_reminder' ),
    Field::inst( 'lead_days' ),
    Field::inst( 'periodicity' ),
    Field::inst( 'automatic_tracking' ),
    Field::inst( 'linked_account' ),
    Field::inst( 'associated_jar' ),
    Field::inst( 'memo' )
    )
    ->process( $_POST )
    ->json();

    [/code]
    [/cp
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    I'd expect that error, at that point if you are using PHP less than 5.3. If you add:

    [code]
    echo phpversion();
    [/code]

    at the top of the file, what does the server then return? (just a sanity check)

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    It returns this:

    PHPVersion :5.4.4
    {"id":-1,"error":"","fieldErrors":[],"data":[],"aaData":[]}
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    i have the same problem:

    Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '('

    on line 13
    and my php version is 5.4.6.
    Is there anything to do?
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    OK instead of :

    [code] use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Validate;[/code]

    put:

    [code]use DataTables\Editor;
    use DataTables\Editor\Field;
    use DataTables\Editor\Format;
    use DataTables\Editor\Join;
    use DataTables\Editor\Validate;
    [/code]

    it works fine for me i hope this will help you.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    That's interesting - the multi-line syntax of `use` should be perfectly okay. Possibly something in PHP has changed... I'll install 5.4.6 on a machine and see if I get the same error. Thanks for your post.

    Allan
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    edited February 2013
    you're welcome lol.
    I'm trying to put both buttons for add/edit/delete ans the swf for copy/excel/pdf export but i can't ?
    Is it possible to put them together or not?
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Certainly is. Just add the export buttons to the aButtons array for your Editor instance. What are you using at the moment?

    Allan
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    edited February 2013
    hi allan,
    I'm using this :
    [code]"oTableTools": {
    "sSwfPath": "TableTools/swf/copy_csv_xls_pdf.swf" ,
    "sRowSelect": "multi",
    "aButtons": [
    { "sExtends": "editor_create", "editor": editor },
    { "sExtends": "editor_edit", "editor": editor },
    { "sExtends": "editor_remove", "editor": editor }
    ]
    },[/code]
    if i remove de aButtons, i can see the swf in place of the buttons, but if i leave the abutons code, my swf dissapear, seems like they are in the same place. I want the swf to be at the right of the search input.
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    edited February 2013
    And for the css i use the original file datatables.editor.css and datatables.Tabletools.css
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    [code]
    "oTableTools": {
    "sSwfPath": "TableTools/swf/copy_csv_xls_pdf.swf" ,
    "sRowSelect": "multi",
    "aButtons": [
    { "sExtends": "editor_create", "editor": editor },
    { "sExtends": "editor_edit", "editor": editor },
    { "sExtends": "editor_remove", "editor": editor },
    'csv',
    'copy' // etc
    ]
    },
    [/code]

    Allan
  • nicolas69nicolas69 Posts: 11Questions: 0Answers: 0
    Thanks it's working fine now!
This discussion has been closed.