Connect a mysql database

Connect a mysql database

iotphoenixiotphoenix Posts: 4Questions: 1Answers: 0

Hi all,

I'm a newbie in development. I have my HTML file.
My js file :
$(document).ready(function () {
$('#tn-data').DataTable({
"processing": true,
"serverSide": true,
"ajax": "./assets/php/server_processing.php",
"language": {
"url": "./assets/json/fr-FR.json",
},
"lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
});
});

My server_processing.php file with credentials to connect the database

In my table I have 35 fields. I want only display columns 2, 4, 5, 8 an 19

Actually in my php file :
// $columns = array(
// array( 'db' => 'Date', 'dt' => 0 ),
// array( 'db' => 'Series', 'dt' => 1 ),
// array( 'db' => 'Surface', 'dt' => 2 ),
// array( 'db' => 'Account', 'dt' => 3 ),
// array( 'db' => 'Lost', 'dt' => 4 )
// );

In my php file I only write 5 fields. Is this the reason I have an error message "Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1" ?

Thank you

Replies

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    The place to start is with the troubleshooting steps at the link in the error:
    http://datatables.net/tn/1

    Let us know what you find.

    Kevin

  • iotphoenixiotphoenix Posts: 4Questions: 1Answers: 0

    Before to post a new discussion, I checked the link in my post and your replie.

    The request is empty and so the response too.

    https://ibb.co/zrGyRLp

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    An empty response is not valid JSON, so that explains why you are getting that error.

    Do you need server-side processing? Or more specifically, how many rows does your table have? Why is the $columns array commented out? What is the rest of the file? We really need more information in order to be able to help.

    Allan

Sign In or Register to comment.