Server side script coming up with blank page (using Ampps)
Server side script coming up with blank page (using Ampps)

Server side script coming up with blank page (using Ampps)
Not sure if I can create a test case when a dB is involved.
I tried to follow this example and I downloaded the ssp.class.php from here and removed the 4 lines as instructed.
This is my html
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="datatables.min.css"/>
<script type="text/javascript" src="jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="datatables.min.js"></script>
<script>
$(document).ready(function() {
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "server_processing.php"
} );
} );
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead><tr>
<th>English</th>
<th>Greek</th>
</tr>
</thead>
</table>
Both server_processing.php and ssp.class.php are in the same folder as the html file.
This is my server processing file
$table = 'mytable';
// 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' => 'English', 'dt' => 0 ),
array( 'db' => 'Greek', 'dt' => 1 )
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => 'mysql',
'db' => 'gloss',
'host' => 'localhost'
);
and this is my dB screenshot https://ibb.co/5KGcB6f
This discussion has been closed.
Answers
Your $(document).ready function is missing a closing script tag.
Thanks!
Now I get:
DataTables warning: table id=example - An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'field list'
And I can see in server_processing.php
// Table's primary key
$primaryKey = 'id';
I try to add Index in one of the columns but it will give the error
1062 - Duplicate entry 'acoustic shock' for key 'PRIMARY'
How can I have the index and allow duplicate entries in a column?
I added an id column and it worked after using
My original SQL to create the table was
What should it be like to include the id column?
Change
$primaryKey = 'id';
to be:Your table already has a primary key, so you can use that.
Allan