installation issue

installation issue

scottgrummscottgrumm Posts: 2Questions: 1Answers: 0
edited April 2021 in Free community support

I would like to buy Editor but am having problems getting the examples to work. I am using a trial of Editor-PHP-2.0.1.zip and have a few days left. I copied Editor-PHP-2.0.1.zip to the web server, made a "editor" directory, unzipped it in the new directory and modified lib/config.php.

I go to the URL on my web server: http://<server/editor/examples/simple/simple.html

A popup with the error is presented:
DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

The response I get (in the developer tools) is:

<?php

/*
 * Example PHP implementation used for the index.html example
 */

// 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\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'datatables_demo' )
    ->fields(
        Field::inst( 'first_name' )
            ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'A first name is required' ) 
            ) ),
        Field::inst( 'last_name' )
            ->validator( Validate::notEmpty( ValidateOptions::inst()
                ->message( 'A last name is required' )  
            ) ),
        Field::inst( 'position' ),
        Field::inst( 'email' )
            ->validator( Validate::email( ValidateOptions::inst()
                ->message( 'Please enter an e-mail address' )   
            ) ),
        Field::inst( 'office' ),
        Field::inst( 'extn' ),
        Field::inst( 'age' )
            ->validator( Validate::numeric() )
            ->setFormatter( Format::ifEmpty(null) ),
        Field::inst( 'salary' )
            ->validator( Validate::numeric() )
            ->setFormatter( Format::ifEmpty(null) ),
        Field::inst( 'start_date' )
            ->validator( Validate::dateFormat( 'Y-m-d' ) )
            ->getFormatter( Format::dateSqlToFormat( 'Y-m-d' ) )
            ->setFormatter( Format::dateFormatToSql('Y-m-d' ) )
    )
    ->debug(true)
    ->process( $_POST )
    ->json();

The PHP tag is not closed so something must be going wrong.

The table does not exist on the MySQL server. Do I need to make it? There is a datatables schema.

I am probably doing something wrong with the installation of DataTables/editor or the server setup but do not know what it is. Any help would be greatly appreciated.

Ubuntu 20.04
Apache: 2.4.41
PHP: 7.4.3
MySQL 8.0.23
The MySQL user uses standard authentication, has 0 for all the account limits, has the DBA Administrative Role (which selects everything) and has all the privileges on all the schemas (%).

editor/lib/config.php:

<?php if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.

// Enable error reporting for debugging (remove for production)
error_reporting(E_ALL);
ini_set('display_errors', '1');


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Database user / pass
 */
$sql_details = array(
    "type" => "Mysql",     // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
    "user" => "auser",          // Database user name
    "pass" => "superSecret",          // Database password
    "host" => "<IP Address>", // Database host
    "port" => "",          // Database connection port (can be left empty for default)
    "db"   => "datatables",          // Database name
    "dsn"  => "charset=utf8mb4",          // PHP DSN extra information. Set as `charset=utf8mb4` if you are using MySQL
    "pdoAttr" => array()   // PHP PDO attributes array. See the PHP documentation for all options
);


// This is included for the development and deploy environment used on the DataTables
// server. You can delete this block - it just includes my own user/pass without making 
// them public!
if ( is_file($_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php") ) {
    include( $_SERVER['DOCUMENT_ROOT']."/datatables/pdo.php" );
}
// /End development include

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • scottgrummscottgrumm Posts: 2Questions: 1Answers: 0
    edited April 2021

    When running:examples/simple/simple.html
    I get:
    DataTables warning: table id=example - An SQL error occurred: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'datatables.datatables_demo' doesn't exist

    When running code generator made I get:
    DataTables warning: table id=testTable - An error occurred while connecting to the database ''. The error reported by the server was: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)
    When config.php uses an IP of hostname or fully qualified hostname.

    It looks like none of the values I put in config.php are getting used as both the database and user are blank strings.

    I modified config.php:

    When I run it I just get:

    $ php config.php 
    Howdy
    $
    
    $ cat config.php 
    <?php
    echo "Howdy\n";
    if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.
    echo "Hi\n";
    <snip>
    

    I'm able to list all the js and css files and get the two files from the CDN from the command line. Does apache2 or php 7.4.3 need the proxy set as root or www-data and not my own user?

    Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    It sounds like you haven't created the databases required by the demo. As it mentions on the installing page, you need "to load your database with the tables and data required for the Editor demos" - for MySQL that's this.

    Could you confirm you've done that, please?

    Collin

This discussion has been closed.