DataTables 1.10 serverside sp.class.php

DataTables 1.10 serverside sp.class.php

kqueekqueekqueekquee Posts: 40Questions: 1Answers: 0
edited February 2014 in DataTables 1.9
i have this message in serverside

Notice: Undefined index: columns in \ssp.class.php on line 159
Notice: Undefined index: draw in \ssp.class.php on line 245

https://github.com/DataTables/DataTables/blob/master/examples/server_side/scripts/ssp.class.php

Replies

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394
    What does the rest of your code look like - i.e. how are you using ssp.class.php?
  • kqueekqueekqueekquee Posts: 40Questions: 1Answers: 0
    mon code

    <?php

    // MYSQL DB table utilisée
    $table = 'communes';
    // Clé primaire
    $primaryKey = 'INSEE';

    // Array des colonnes à lire et à transmettre vers DataTables.

    $columns = array(
    array( 'db' => 'CRAC', 'dt' => 0 ),
    array( 'db' => 'REGION', 'dt' => 1 ),
    array( 'db' => 'INSEE', 'dt' => 2 ),
    array( 'db' => 'NOM', 'dt' => 3 ),
    );

    $config = parse_ini_file( $_SERVER['DOCUMENT_ROOT'] . 'config.ini' , true);
    // connexion Base de données MYSQL serveur connection information
    $sql_details = array(
    'user' => $config["BDD"]["identifiant"],
    'pass' => $config["BDD"]["motdepasse"],
    'db' => $config["BDD"]["nombdd"],
    'host' => $config["BDD"]["hote"]
    );

    require( 'ssp.class.php' );

    echo json_encode( SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns ));

    ?>
  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin
    And are you sending the data as GET or POST (the code above suggests GET). It would be very useful if you could link to the page please.

    Allan
  • MuckelMuckel Posts: 7Questions: 1Answers: 0

    I have the same problem. Have you got solved the problem kqueekquee?

  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin

    @Muckel - Can you link use to your page so we can debug it and try to provide some assistance please?

    Allan

  • sylvie_yunjaesylvie_yunjae Posts: 3Questions: 1Answers: 0

    Ahhh... still no answer..... I get stuck with the exact same error (-____-")

    Notice: Undefined index: columns in \ssp.class.php on line 159
    Notice: Undefined index: draw in \ssp.class.php on line 245

    This is how I wrote my server processing code :
    http://pastebin.com/wSG3JuBy

    And this is the error I get :
    http://pasteboard.co/y6zkR0R.jpg

    And I didn't change anything from ssp.class.php

    Please.. can anyone solve this XD
    Looks like many people got stuck in the sama error

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    The best approach is to provide a link to the page showing the error. (Allan already asked twice.)

  • sylvie_yunjaesylvie_yunjae Posts: 3Questions: 1Answers: 0

    Ohh.. thanks fast 4 response.

    Errr... I'm sorry, I already read too.. but I'm having trouble upload my page on server for some reasons.
    But I'll try. I already attached the page showing the error too as a picture above, please kindly take a look

    It was exactly as I mentioned .above, I didn't change ssp.class.php, I just change the processing code (the code I posted before). I'm still working on it too

  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin

    One thing that does spring to mind - have you use the serverSide option to enable server-side processing?

    Again - with a test case we would have spotted that immediately. You will not receive any further replies for me without a link to a test case.

    Thanks,
    Allan

  • GodsDeadGodsDead Posts: 5Questions: 1Answers: 0

    I have this exact same Error, I have only edited the default scripts to display my data.

  • vivanetvivanet Posts: 1Questions: 0Answers: 0
    edited October 2014

    Hi,

    I had the same problem but now it works - after a lot of hours. The encoded array from ssp.class.php was not in UTF-8 what is needed for json_encode.

    In the ssp.class.php at about #267:

                $db = @ new PDO(
                    "mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
                    $sql_details['user'],
                    $sql_details['pass'],
                    array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )
                );
    

    Directly after this you have to place the following:

                $db->query("SET NAMES 'utf8'");
    

    This solved it for me.

  • vkvaradhavkvaradha Posts: 7Questions: 2Answers: 0

    Still i have the same error. while testing the example code which provided in the source zip.

  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin

    @vkvaradha - Please link to a test case showing the issue.

    Allan

  • vkvaradhavkvaradha Posts: 7Questions: 2Answers: 0

    i just replied on github issues. help me on this.

  • surendersurender Posts: 1Questions: 0Answers: 0

    Hi,

    I had the same problem but now it works - after a lot of hours. The encoded array from ssp.class.php was not in UTF-8 what is needed for json_encode.

    In the ssp.class.php at about #267:
    $db = @ new PDO(
    "mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
    $sql_details['user'],
    $sql_details['pass'],
    array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )
    );

    Directly after this you have to place the following:
    $db->query("SET NAMES 'utf8'");

    This solved it for me.

    This did the magic as said by @vivanet

  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin

    Good to hear - thanks for the feedback.

    Allan

  • kqueekqueekqueekquee Posts: 40Questions: 1Answers: 0

    Thanks . Merci beaucoup

This discussion has been closed.