Working on Remote server - Error

Working on Remote server - Error

edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

Hi, i upload my script to PHP (v 5.3.29) server;
I get Ajax errors - 500 (Internal Server Error) ;

So i figured out the issue;

when i write like this everything is fine, there is no problem;

//if edit mode and password is blank, do not save.
    $editor->on( 'preEdit', function ( $e, $id, $values ) {
    if ( $values['users']['user_pass'] === '' ) {
    $e->field( 'users.user_pass' )->set( false );
    }
    } );


    //if create - validate for pass
    $editor->on( 'preCreate', function ( $editor, $values ) {
    $editor->field( 'users.user_pass' );
    $editor->validator( 'Validate::notEmpty' );
    } );

but in my original script in localhost, the code is like below;

    //if edit mode and password is blank, do not save.
    ->on( 'preEdit', function ( $e, $id, $values ) {
    if ( $values['users']['user_pass'] === '' ) {
    $e->field( 'users.user_pass' )->set( false );
    }
    } )


    //if create - validate for pass
    ->on( 'preCreate', function ( $editor, $values ) {
    $editor
    ->field( 'users.user_pass' )
    ->validator( 'Validate::notEmpty' );
    } );

so is there a way to make the original code work on remote server without any changes? Cause i have to update so many rows.
Thanx

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin
    Answer ✓

    Does the server's error log show any information that explains what the issue is? I don't immediately see what the error would be in the above.

    Thanks,
    Allan

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    Sorry Allan, i really don't know how to find server's error log.
    this is the error i get.

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    I can modify the scripts but i couldn't manage to make work one row,
    Here is the code working on local server;

                     Field::inst( 'users.user_photo' )
            ->setFormatter( 'Format::ifEmpty', null )
            ->upload( Upload::inst( '../uploads/user_photos/__ID__-__NAME__' )
                ->db( 'userphotos', 'id', array(
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE
                ) )
                ->validator( function ( $file ) {
                    return$file['size'] >= 5000000 ?
                        "Files must be smaller than 5MB" :
                        null;
                } )
    
                ->dbClean( function ( $data ) {
                // Remove the files from the file system
                for ( $i=0, $ien=count($data) ; $i<$ien ; $i++ ) {
                    unlink( '../uploads/user_photos/'.$data[$i]['id'].'-'.$data[$i]['filename'] );
                }
    
                // Have Editor remove the rows from the database
                return true;
                } )
                ->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )
            ),
    

    I realised that when i remove the below row, it works perfect.

    ->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )

    Do you have any suggestions ? How can i modify this row?

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    changing this,

    //->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )

    to this,

    ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image" )

    solved the problems.
    I think it is something about the server.
    Thanx.

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin

    Ah!! [] is PHP 5.4 array syntax. 5.3 requires array() syntax.

    The doc comments in the Upload.php file appear to use the 5.4 style, which I'll change for the next release. Is that where you found the example code for this, or was it somewhere else?

    Allan

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    Hi Allan,

    I found the example on the new examples while i was exploring editor 1.6.1.

    There is one more thing,

    i think this line gives an error in php 5.3 (Master/Child table example)

    echo json_encode( [ "data" => [] ] );
    

    Any suggestions?

    Thank you.

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

    I solved the problem;

    This works in PHP 5.3

    echo json_encode(array("data" => ""));

This discussion has been closed.