problem with the Server-side processing AND search

problem with the Server-side processing AND search

yurispyyurispy Posts: 29Questions: 6Answers: 0

Good evening,
I have a problem with the Server-side processing method.
The page is displayed correctly as you can see on the screenshot, as well as the following pages etc.
But if I search for a term (ex: ROUNDUP) As soon as I write a single word, I have the error (DataTables warning: table id = hor-minimalist-b - An SQL error occurred: SQLSTATE [HY093]: Invalid I do not know what to do with it.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    I would suggest starting by debugging the SQL that is being executed. Have you written your own server-side script or are you using a library one from somewhere?

    Allan

  • yurispyyurispy Posts: 29Questions: 6Answers: 0

    The one of the example.

    <?php
    /*
     * DataTables example server-side processing script.
     *
     * Please note that this script is intentionally extremely simply to show how
     * server-side processing can be implemented, and probably shouldn't be used as
     * the basis for a large complex system. It is suitable for simple use cases as
     * for learning.
     *
     * See http://datatables.net/usage/server-side for full details on the server-
     * side processing requirements of DataTables.
     *
     * @license MIT - http://datatables.net/license_mit
     */
     
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * Easy set variables
     */
     
    // DB table to use
    $table = 'ephy_copy';
     
    // Table's primary key
    $primaryKey = 'id';
     
    // Array of database columns which should be read and sent back to DataTables.
    // The `db` parameter represents the column name in the database, while the `dt`
    // parameter represents the DataTables column identifier. In this case simple
    // indexes
    $columns = array(
                array( 'db' => 'id', 'dt' => 0 ),
                array( 'db' => '(produit) type produit', 'dt' => 1 ),
                array( 'db' => '(produit) numero AMM', 'dt' => 2 ),
                array( 'db' => '(produit) nom produit', 'dt' => 3 ),
                array( 'db' => '(produit) seconds noms commerciaux', 'dt' => 4 ),
                array( 'db' => '(produit) titulaire', 'dt' => 5 ),
                array( 'db' => '(produit) type commercial', 'dt' => 6 ),
                array( 'db' => '(produit) gamme usage', 'dt' => 7 ),
                array( 'db' => '(produit) mentions autorisees', 'dt' => 8 ),
                array( 'db' => '(produit) Substances actives', 'dt' => 9 ),
                array( 'db' => 'identifiant usage lib court', 'dt' => 10 ),
                array( 'db' => 'identifiant usage', 'dt' => 11 ),
                array( 'db' => 'date decision', 'dt' => 12 ),
                array( 'db' => 'stade cultural min', 'dt' => 13 ),
                array( 'db' => 'stade cultural max', 'dt' => 14 ),
                array( 'db' => 'etat usage', 'dt' => 15 ),
                array( 'db' => 'dose retenue', 'dt' => 16 ),
                array( 'db' => 'dose retenue unite', 'dt' => 17 ),
                array( 'db' => 'delai avant recolte jour', 'dt' => 18 ),
                array( 'db' => 'delai avant recolte bbch', 'dt' => 19 ),
                array( 'db' => 'nombre max d\'application', 'dt' => 20 ),
                array( 'db' => 'date fin distribution', 'dt' => 21 ),
                array( 'db' => 'date fin utilisation', 'dt' => 22 ),
                array( 'db' => 'condition emploi', 'dt' => 23 ),
                array( 'db' => 'ZNT aquatique (en m)', 'dt' => 24 ),
                array( 'db' => 'ZNT arthropodes non cibles (en m)', 'dt' => 25 ),
                array( 'db' => 'ZNT plantes non cibles (en m)', 'dt' => 26 ),
                array( 'db' => 'mentions autorisees', 'dt' => 27 ),
                array( 'db' => 'f28', 'dt' => 28 )
    
    );
     
    $sql_details2 = array(
        'user' => '  ',
        'pass' => '  ',
        'db'   => 'acm_db',
        'host' => 'localhost'
    );
     
    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * If you just want to use the basic configuration for DataTables with PHP
     * server-side, there is no need to edit below this line.
     */
     
    require( 'ssp.class.php' );
     
    echo json_encode(
        SSP::simple( $_GET, $sql_details2, $table, $primaryKey, $columns )
    );
    
    <?php
    >
    ?>
    
    
    
  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    Do you really have your database column names such as (produit) type produit (i.e. with parenthesis and spaces in them)?

    You'll probably need to modify the demo ssp class to escape them if so.

    Allan

  • yurispyyurispy Posts: 29Questions: 6Answers: 0

    Yes exactly the same. The easiest way would be to change the column names in the database.
    I would not be how to take to change the ssp class.

    Thank you for your help.

This discussion has been closed.